[SOLVED] How to expand TIniPropStorage by some more variables to save and reload lazarus / 31-LCL ---------------------------------------------------------------------- Hartmut · 2016-11-26 16:07 My program uses a TIniPropStorage to save some data in an INI-file which works fine. I want to add some of my own variables to that INI- file. So I thought I could add these variables to type TForm1 and would then be able to add them to the INI-file, but this does not work: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, IniPropStorage; type  { TForm1 }  TForm1 = class(TForm)  IniPropStorage1: TIniPropStorage;  procedure FormCreate(Sender: TObject); private  { private declarations } public  { public declarations }  x1: double;  // 2 variables to save in the INI-file too:  x2: longint; end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);   begin   Form1.SessionProperties:='Top;Left;x1;x2;';   end; end. My INI-file contains only 'Top' and 'Left', 'x1' and 'x2' are missing. I think the reason is, that TIniPropStorage can only handle objects or classes, which are a successor of a certain object or class. Is that right? Which is the object or class which I need and can I drag it in Lazarus to my Form1 or how do I get it there? ---------------------------------------------------------------------- M+AUDIO · 2016-11-26 21:25 Hi, This works: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit umain; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,  IniPropStorage; type   { TForm1 }   TForm1 = class(TForm)    IniPropStorage1: TIniPropStorage;    procedure FormCreate(Sender: TObject);    procedure FormShow(Sender: TObject);    procedure IniPropStorage1RestoringProperties(Sender: TObject);  private    FField1: Double;    FField2: Integer;  public   published    property Field1: Double read FField1 write FField1;    property Field2: Integer read FField2 write FField2;  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);begin  Field1 := 0.313;  Field2 := 14;end; procedure TForm1.FormShow(Sender: TObject); //just to debug, not needed.begin  ShowMessage(FloatToStr(Field1));end; procedure TForm1.IniPropStorage1RestoringProperties(Sender: TObject);begin  SessionProperties := 'Top;Left;Field1;Field2;';end; end. Notice defining SessionProperties in OnRestoringProperties event of the IniPropStorage1 and turning variables to published properties. ps: also have a look here in the wiki. ---------------------------------------------------------------------- Hartmut · 2016-11-26 21:47 Great, it works and is very easy. You need no special object or class, just a published property is enough. Thanks a lot to M+AUDIO for your help. ---------------------------------------------------------------------- Edson · 2016-11-27 17:27 You can use https://github.com/t-edson/MiConfig to save/restore fields in INI and XML files. Additionally, it let you edit, easily, these fields in a dialog form. ---------------------------------------------------------------------- Hartmut · 2016-11-28 17:25 Thanks to Edson for your link. Although my solution is implemented already I will have a look into.