Page 1 of 1

Adding String in a ListView

Posted: Tue Oct 05, 2004 4:21 pm
by thyr0x1ne
Im currently looking for "loading" a text file in a ListView Gadget , each line of the text on a ListView one.

My problem is that the

SendMessage_(GadgetID(#ListView_0), #LB_ADDSTRING, 0, String)

doesnt seem to work for me .. i bet i m wrong with the OpenFile command trying to retrieve each line then send it to ListView via SendMessage_ ...

could someone give me a hint to create a routine retrieving each line strings after a OpenFile command on a .txt file ?

Posted: Tue Oct 05, 2004 5:40 pm
by FloHimself

Code: Select all

Procedure FillLVGWithTextFile(LVGadget.l, FileName$)
  If IsGadget(LVGadget) <> 0
    FileNr.l = ReadFile(#PB_Any, FileName$)
    If FileNr <> 0
      While Eof(FileNr) = 0
        AddGadgetItem(LVGadget, -1, ReadString()) 
      Wend
      ProcedureReturn #True
    EndIf
  EndIf
  ProcedureReturn #False
EndProcedure

Posted: Tue Oct 05, 2004 7:11 pm
by thyr0x1ne
more than a hint , the right part of what i wanted to do ... just a few changes and now it works perfectly , ty very much!

Posted: Tue Oct 05, 2004 7:30 pm
by FloHimself
np!
be sure to add a CloseFile() to the function to cleanup.. just forgot that.. (as always) :(