Recent

Author Topic: TStringList Question  (Read 203 times)

JLWest

  • Hero Member
  • *****
  • Posts: 1105
TStringList Question
« on: July 02, 2022, 12:20:08 am »
Is there a way to load a text file into a TStringList. I'm loading the file into a listbox now but would like it in a TStringList.

Code: Pascal  [Select][+][-]
  1.  Var Valid: Boolean;
  2.   TList: TStringList;
  3.   FileName: String;
  4.  begin
  5.  FileName:='S4H=.txt';
  6.  TList := TStringList.Create;
  7.  Listbox1.Items.LoadFromFile(FileName);
  8.  
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

lainz

  • Hero Member
  • *****
  • Posts: 3966
Re: TStringList Question
« Reply #1 on: July 02, 2022, 12:29:29 am »
Code: Pascal  [Select][+][-]
  1.  TList := TStringList.Create;
  2. TList.LoadFromFile('file.txt');
  3.  

JLWest

  • Hero Member
  • *****
  • Posts: 1105
Re: TStringList Question
« Reply #2 on: July 02, 2022, 01:00:11 am »
Yea, Works Great
Thanks.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

 

TinyPortal © 2005-2018