Quote |
The comments are full of odd characters that break things. Using blobs might help, but then not sure of search capabilities.... It is the past 10% of the data that is difficult. |
Quote |
Does 750 items warrant using an sql database? It would be easy moving forward. |
Code Sample |
#!/bin/murgaLua -- mydsl info browser, 2008 mikshaw -- -- Changelog (yyyy/mm/dd) -- 2008/01/14: Fixed display of incorrect duplicate info file -- Check for trailing spaces in title string -- 2008/01/13: start of project listfile="/home/dsl/WORK/mydsl_master_list/list.txt" inputfile=io.open(listfile) if not inputfile then print("can't open "..listfile) os.exit(1) end data=inputfile:read("*a") inputfile:close() w=fltk:Fl_Window(350,400,"MyDSL Info Search") b_loc=fltk:Fl_Choice(100,10,240,30,"category: ") b_loc:callback( function() while b_files:size()>1 do b_files:remove(0) end b_files:redraw() for i=1,info_count do if info[i].location==b_loc:text() then b_files:add(info[i].title) end end b_files:value(0) b_files:do_callback() end ) b_files=fltk:Fl_Choice(100,40,240,30,"file: ") b_files:callback( function() for i=1,info_count do if info[i].title == b_files:text() and info[i].location == b_loc:text() then info_display_buffer:text(info[i].text) break end end end ) info_display=fltk:Fl_Text_Display(10,70,330,280) --info_display:textfont(fltk.FL_COURIER) info_display:textfont(fltk.FL_SCREEN) info_display:textsize(12) info_display_buffer=fltk:Fl_Text_Buffer() info_display:buffer(info_display_buffer) download=fltk:Fl_Button(10,350,120,30,"Download") install=fltk:Fl_Button(130,350,120,30,"Download and Install") install:callback( function() print("mydsl-load "..b_files:text().." "..b_loc:text()) end ) info={} info_count=0 -- breaks up each info file into a separate string for s in string.gmatch(data,"(Location:.-\n)Location:") do info_count=info_count+1 info[info_count]={ location=string.match(s,"Location:%s*(.-)%s*\n"), title=string.match(s,"Title:%s*(.-)%s*\n"), text=s } b_loc:add(info[info_count].location) end b_loc:value(0) b_loc:do_callback() w:resizable(info_display) w:show() Fl:run() |