Warning: include(../mainbanner.htm) [function.include]: failed to open stream: No such file or directory in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 31

Warning: include(../mainbanner.htm) [function.include]: failed to open stream: No such file or directory in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 31

Warning: include() [function.include]: Failed opening '../mainbanner.htm' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 31

Warning: include(../left.htm) [function.include]: failed to open stream: No such file or directory in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 52

Warning: include(../left.htm) [function.include]: failed to open stream: No such file or directory in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 52

Warning: include() [function.include]: Failed opening '../left.htm' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 52
Delphi Tutorial

Save Your Setting with INI File

INI files represented file used to store various of setting or initialization or configuratoin of an application that run on Windows environment. INI files is actually like file text so you can read and edit in Notepad.

INI files have very simple structures that consist by group of Section, Key And Value. See following below.

[Section]
Key = Value

Section shares some setting. Key as one of settinsg of a Section, while Value represent the value of key can be in number, string, boolea.and etc.

Now, most application using registry to store their application information. Although INI files is old method, but some software still use it because its simple to use.

You must have add Inifiles unit ini uses clause to access INI files. This unit have some procedure that can be used to write and read INI files. For example, i show you some procedure read and write to INI file. See following below:
WriteInteger, WriteString, WriteBool, WriteDate, WriteDateTime, WriteTime, Writefloat, ReadInteger, ReadString, ReadBool, ReadDate, ReadDateTime, ReadTime, ReadFloat

Declare variable TInifile to memory allocation.

procedure AccessingIniFile;
var MyIni: TInifile; //define TInifile variable begin //create TInifile variable into memory MyIni:= TInifile.Create('setting.ini'); try //Accesing ini file 'setting.ini' ... finally //freeing variable MyIni from memory MyIni.Free; end; end;

Dont forget to deallocated it from memory after using TInifile variable.

This example is a part of Phonebook application where INI files (called used to store form location.that called is setting.ini [is] last position form and when this application [is] run, hence position form will be at the last position.

uses Inifiles;
procedure TForm1.SaveSetting(Left,Top: integer);
var
  MyIni: TInifile;
begin //Save form position to INI file MyIni:= TInifile.Create(ExtractFilePath(Application.ExeName) +'setting.ini'); try { Write the form position } MyIni.WriteInteger('Position', 'Left', Left); MyIni.WriteInteger('Position', 'Top', Top); finally MyIni.Free; end; end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin //Save setting SaveSetting(Left, Top); end;

This following is INI file that created by SaveSetting() procedure. You can use Notepad to see it.
[Position]
Left=801
Top=251



Warning: include(../ulink180x90.php) [function.include]: failed to open stream: No such file or directory in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 154

Warning: include(../ulink180x90.php) [function.include]: failed to open stream: No such file or directory in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 154

Warning: include() [function.include]: Failed opening '../ulink180x90.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 154

When program started again, The form position will be set to value from setting.ini. See following below where ReadSetting procedure shows how to get the values.

uses Inifiles;
procedure TForm1.ReadSetting;
var
  MyIni: TInifile;
begin //Read form position from INI file MyIni:= TInifile.Create(ExtractFilePath(Application.ExeName)+ 'setting.ini'); try { Read the form position } Left:= MyIni.ReadInteger('Position', 'Left', 0); Top:= MyIni.ReadInteger('Position', 'Top', 0); finally MyIni.Free; end; end; procedure TForm1.FormCreate(Sender: TObject); begin ReadSetting; ... ... end;


Warning: include(../right.htm) [function.include]: failed to open stream: No such file or directory in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 210

Warning: include(../right.htm) [function.include]: failed to open stream: No such file or directory in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 210

Warning: include() [function.include]: Failed opening '../right.htm' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 210

Warning: include(../bottombanner.htm) [function.include]: failed to open stream: No such file or directory in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 225

Warning: include(../bottombanner.htm) [function.include]: failed to open stream: No such file or directory in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 225

Warning: include() [function.include]: Failed opening '../bottombanner.htm' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/makedata/public_html/delphitutorial/save setting with ini.php on line 225