Welcome, Guest
Username: Password: Remember me
Discussions for CodeTyphon Object Pascal Programming Language
  • Page:
  • 1

TOPIC:

Ini Files 10 months 2 weeks ago #18253

  • Joao Barbosa
  • Joao Barbosa's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 38
  • Thank you received: 1
Reading from ini files does not seem to work in the current versions of CT. Tried on macOS and windows with no luck

procedure TMainForm.FormCreate(Sender: TObject);
v
begin
  IniPath := Application.Location;
  IniFile := 'pisinvoicing.ini';
//  callResult := iniRead(iniPath);
     Memo1.Clear;
     Memo1.Append('Inipath =' +IniPath);
     Memo1.Append('BUndle Path = '+ExtractFilePath(GetBundlePath));
//  ShowMessage(ExtractFilePath(GetBundlePath));
  //  Users/joaobarbosa/Data/PSINVOICING.FDB
//  MyIniFile := TIniFile.Create(ExtractFilePath(GetBundlePath) + IniFile);
//  MyIniFile := TIniFile.Create('/Users/joaobarbosa/Myprojects/PInvoicing/Invoicing/pisinvoicing.ini');
//  MyIniFile := TIniFile.Create(IniPath+'pInvoicing.ini');

  try
     with MyIniFile do
     begin
       AppServer := MyIniFile.ReadString('SYSPARAMS', 'AppServer', '');
       AppDatabase := MyIniFile.ReadString('SYSPARAMS', 'AppDatabase', '');
     end;
   finally
     // After the ini file was used it must be freed to prevent memory leaks.
     MyIniFile.Free;
   end;
   dmPis.psconnection.HostName:=AppServer;
   dmPis.psconnection.Database:=AppDatabase;
   dmPis.psconnection.Connect;
   VatNo := dmPis.CompanyQry.FieldByName('taxno').AsString;
   CompanyName := dmPis.CompanyQry.FieldByName('companyname').AsString;
   lblCompanyName.Caption:=CompanyName;
 Memo1.Append('Host=' +AppServer);
 Memo1.Append('Db=' + AppDatabase); //
end; 
 

Please Log in or Create an account to join the conversation.

Last edit: by Joao Barbosa.

Ini Files 10 months 2 weeks ago #18259

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 1130
  • Thank you received: 170
Where is MyIniFile := TIniFile.Create(

//  MyIniFile := TIniFile.Create(ExtractFilePath(GetBundlePath) + IniFile);
//  MyIniFile := TIniFile.Create('/Users/joaobarbosa/Myprojects/PInvoicing/Invoicing/pisinvoicing.ini');
//  MyIniFile := TIniFile.Create(IniPath+'pInvoicing.ini');

Try and TMemIniFile Class
PilotLogic Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Matis A..

Ini Files 10 months 2 weeks ago #18261

  • Joao Barbosa
  • Joao Barbosa's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 38
  • Thank you received: 1
just under the Mainform class
var
MainForm: TMainForm;

MyIniFile: TiniFile;
IniPath : string;
IniFile : String;

Please Log in or Create an account to join the conversation.

Ini Files 10 months 2 weeks ago #18262

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 1130
  • Thank you received: 170
Not the declaration of MyIniFile

but the creation of MyIniFile
MyIniFile := TIniFile.Create(FooFile);

Please,
check if FooFile exists before
create TIniFile class variable;
MyIniFile := TIniFile.Create(FooFile);

 
PilotLogic Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Matis A..

Ini Files 10 months 2 weeks ago #18264

  • Joao Barbosa
  • Joao Barbosa's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 38
  • Thank you received: 1
ok found the issue, which was not happening in previous versions because I used the same project I was using before. the creation order of the forms in autocreate, I had to put the data module form first then it all works. Even the edit boxes on the form work.

Thank you for your help.

Please Log in or Create an account to join the conversation.

Ini Files 10 months 2 weeks ago #18266

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 1130
  • Thank you received: 170
Thanks Sir
PilotLogic Core Programmer

Please Log in or Create an account to join the conversation.

  • Page:
  • 1