Ini files

Learn how you can store App data in the end users roaming data profile.

You may clone all examples from git at this repository: https://github.com/SigmaEstimates/AppScript-Examples.git

Learn how you can store App data in the end users roaming data profile. This enables you to create specific settings for your App, based on user interaction and configuration.

uses
  System.IO.Inifiles;

const
  //Inifile will be stored in %APPDATA%\CodeGroup\Sigma Install Folder Name\myinifile.ini
  sInifileName = '%sigma_currentuser%\myinifile.ini';

var Username: string;

procedure LoadSettings;
begin
  var IniFile := TMemoryIniFile.Create;
  try
    IniFile.LoadFromFile(sInifileName);
    Username := IniFile.ReadString('Userinfo', 'Username', '');
  finally
    IniFile.Free;
  end;
end;

procedure SaveSettings(Username: string);
begin
  var IniFile := TMemoryIniFile.Create;
  try
    IniFile.LoadFromFile(sInifileName);

    IniFile.WriteString('Userinfo', 'Username', Username);
    IniFile.SaveToFile(sInifileName);
  finally
    IniFile.Free;
  end;
end;

Username := 'TheUserName';
SaveSettings(Username);
Username := '';
LoadSettings();

showmessage(Username) ;