This is a GUI app, which should be simple - but not for me. I am trying to read from a text file, which only has words seperated by commas. Each word should be listed in a listbox. The way I have done it (see code) sort of works, but.. The very last word is not listed in the box - I guess I can work that one out myself somehow. But another problem is, if there is more than one line in the text file, the first word is also not listed. This puzzles me. I'm not very good at this yet, but I keep trying..
I am kind of hoping that there is a way more efficient way of doing this, and that someone can help me with improving this method.
I have been sitting with this most of the day, so I hope someone can help me out.. :(
I am kind of hoping that there is a way more efficient way of doing this, and that someone can help me with improving this method.
I have been sitting with this most of the day, so I hope someone can help me out.. :(
Local style = WINDOW_TITLEBAR Local MainWindow:TGadget=CreateWindow("no title yet", 200,200,400,400,Null,style) Local Menu:TGadget=CreateMenu("Test Menu",0,WindowMenu(MainWindow)) CreateMenu "Preferences",100,Menu CreateMenu "Exit",101,Menu UpdateWindowMenu MainWindow Local List:TGadget=CreateListBox(20,40,150,300,MainWindow) Local label1:TGadget=CreateLabel("ListBox:",20,20,100,20,MainWindow) 'read from database file START temp$="" file:TStream=ReadFile("test.txt") While Not Eof(file) b=ReadByte(file) If Chr(b)="," Then AddGadgetItem List,temp$ temp$="" Else temp$:+Chr(b) EndIf Wend CloseFile(file) 'read from database file END Repeat WaitEvent() Until EventID()=EVENT_WINDOWCLOSE End