TIP: Click on subject to list as thread! ANSI
echo: delphi
to: JON HUNT
from: COLIN TOWERS
date: 1998-01-03 21:15:00
subject: INI File

Wow, it's Jon!
Jon Hunt was passing little notes around the room to All..
 JH> [DATA]
 JH> G:\COMMS\DATA\ADDRESS.DAT
Sounds like you want to look at the code window of your main form, and bung a 
global variable in there - so before the 'implementation' line, chop in
var myfilename : String;
Now, the way I'd do it is by storing it in the registry - but that's a little 
more complex - so doing it by the method you use, create a FormCreate event 
for your main form:
<<
Procedure TMainForm.FormCreate(Sender : TObject);
Var INIFile : TextFile; I : Integer; S : String;
Begin
 myfilename:='DEFAULT.DAT';
 AssignFile(INIFile,'C:\Whatever.Ini');
 Repeat I:=IOResult; Until I=0; {Clear out any previous IO Errors}
 {$I-}
 Reset(IniFile);
 {$I+}
 I:=IOResult;
 If I=0 then begin {Reset went fine}
  While Not EOF(IniFile) do begin
   ReadLn(IniFile,S);
   If Not(Eof(IniFile)) and (S='[DATA]') then ReadLn(IniFile,myfilename);
  end;
  CloseFile(INIFile);
 end;
end;
<<
And I think the syntax is correct. You could also place this in the 
initialization section of the unit -- you may want to do that. If you need 
the variable outside the unit, just put the main unit in the uses clause 
(File.. Use Unit).
Any problems, and I'd be glad to help.
--
Colin - ct219@cam.ac.uk                   "Say yes, at least say Hello..."
--- Terminate 5.02/Pro*at
---------------
* Origin: Colin's Pad! (2:254/211.8)

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™.