TIP: Click on subject to list as thread! ANSI
echo: delphi
to: ALEX TRUBIN
from: GARY WEINFURTHER
date: 1997-05-30 07:21:00
subject: TStrings, TIniFile

Alex Trubin mentioned this to All:
 AT>     Can someone help me with following problem:
 AT> I try to open and to read file 'SOME.INI'
 AT> procedure TForm1.Create(Sender: TObject);
 AT>     var    S1: TStrings;
 AT>            F : string;
 AT>         begin
 AT>            F:='SoMe.InI';
 AT>            S1:= TStrings.Create;
 >> S1.LoadFromFile(F);    <- Here i have ErroR "EAccessViolation"
The problem is that you shouldn't be using TStrings.  It has no ability to 
store strings by itself.  Use TStringList instead.  Or use TIniFile as 
follows:
   IniFile := TIniFile.Create('some.ini');
   try
       Value := IniFile.ReadString('Section', 'Key', 'DefaultValue');
   finally
       IniFile.Free;
   end;
                                ...Gary
--- GoldED 2.41
---------------
* Origin: Nobody expects the Flying Circus BBS! (1:2410/905)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.