Page 1 of 1

[DONE] Adding items from a file to a ListIconGadget,

Posted: Sat Apr 03, 2010 5:47 pm
by PresFox
Hello,

I am trying to populate a listicongadget from a file.

This is the code i am using:

Code: Select all

Procedure populate_list()

  If ReadFile(0, "Landers.dat")   ; if the file could be read, we continue...
    While Eof(0) = 0           ; loop as long the 'end of file' isn't reached
      landers$ = ReadString(0)
      ; explode the string
      
      AddGadgetItem(#ListIcon_1,-1,landers$)
           
    Wend
    CloseFile(0)               ; close the previously opened file
  Else
    MessageRequester("Information","Couldn't open the file!")
  EndIf

  EndProcedure
The procedure works, but it loops endlessly, instead of stopping at the end of the file, showing the same line over and over again. Why is it doing this?

Re: Adding items from a file to a ListIconGadget, endless lo

Posted: Sat Apr 03, 2010 6:14 pm
by Michael Vogel
Your code looks fine for me, so maybe the problem is in your text file?
Just add a debug ":"+landers$+":" after reading from the file to see, what kind of data will be read from the file...

Michael

Re: Adding items from a file to a ListIconGadget, endless lo

Posted: Sat Apr 03, 2010 6:18 pm
by PresFox
debug also shows a endless row of the same (single) line in the file

Re: Adding items from a file to a ListIconGadget, endless lo

Posted: Sat Apr 03, 2010 6:27 pm
by PresFox
This was my mistake, i put a call to the procedure in the main loop, so it was called over and over again

works fine now