List Box question !
BlitzPlus Forums/BlitzPlus Beginners Area/List Box question !
| ||
Hey, I can't figure out how to retrieve the items contained in a List Box . I mean, let's say we have 30 items in this list box. By pushing a button, I want the 30 items to be written to a txt file, but how do I get back theses 30 items ? |
| ||
You have to get each item text, and then just write them to a file. When you open the file back up, you just have read the string, and make an item with that string. |
| ||
But, how do I go from an item to an item ? The index # wouldn't be organized, as I have many gadgets and entries stuff... Would it be with a 'Eof' ? 'surprised' I understand the string conversion process. |
| ||
Do you mean this: Window=CreateWindow( "...",0,0,160,120,0,1) ListBox=CreateListBox( 0,0,130,70,window) For a=0 To 29 AddGadgetItem ListBox,"... - "+a Next SelectGadgetItem ListBox,0 While WaitEvent()<>$803 Wend file=OpenFile("DotDotDot.txt") For b=0 To 29 main$= GadgetItemText$(ListBox,b) WriteLine(file,main$) Next FreeGadget ListBox CloseFile file ListBox=CreateListBox( 0,0,130,70,window) file=OpenFile("DotDotDot.txt") For b=0 To 29 main$=ReadLine(file) AddGadgetItem ListBox,Main$ Next While WaitEvent()<>$803 Wend End |
| ||
Yeah, but the Indexes will not be organized as 1,2,3,4... It will be more like 2,40,42,46,48,53,57... then I am having a problem to retrieve the Item as the indexes aren't organized... Anyone have a solution/idea how to work this out ? Thank you for the support :) |
| ||
Hmm... Instead of giving code I'll give a therory. Save Item From Listbox. Also Save Index On Next Line. So you get: ... 1 2 ... 4 58 In the file. Then read both to temporary locations, sort them, and then re-read them. |
| ||
I think, I get your idea, but I am not convinced, however, you bring me the idea of using temporary files while working the listing. I guess this is how it has to be worked? The Listbox gadget would be only a reader (reading a tmp file), the buttons import,add,delete will work on a tmp file and not on the Listbox gadget. Then it will be easy to export! :) Yeah should work! Awesome :) Thank you for the help, I appreciate ! I am still open to any other solution, more simple/easy.... tested... :) |
| ||
No problem, I like to think people would do the same for me, so in some way, some day, I will be returned... |