Adding String in a ListView

Just starting out? Need help? Post your questions and find answers here.
thyr0x1ne
User
User
Posts: 18
Joined: Sat Feb 14, 2004 11:38 pm

Adding String in a ListView

Post 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 ?
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post 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
thyr0x1ne
User
User
Posts: 18
Joined: Sat Feb 14, 2004 11:38 pm

Post 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!
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

np!
be sure to add a CloseFile() to the function to cleanup.. just forgot that.. (as always) :(
Post Reply