1 (edited by domebil 2018-09-04 11:25:23)

Topic: code no longer working in the latest version

procedure Form1_Button10_OnClick (Sender: string; var Cancel: boolean);
var
  Settings_ini: TStringList;
  ServerLine,FilePath,FileName,Directory: String;
  Len: Integer;
  begin
    Settings_ini := TStringList.Create;
    Settings_ini.LoadFromFile ('Settings.ini');
    ServerLine := Settings_Ini[4];
    Settings_ini.Free;
    Len := Length(ServerLine) - 7;
    FilePath := Copy(ServerLine, 8, Len);
    If Copy(ServerLine,1,7) <> 'server=' then Form1.Label9.Caption := ExtractFilePath(Application.ExeName)+'sqlite.db'
      else Form1.Label9.Caption := FilePath;
begin
    Directory := '';
    FileName := ExtractFileName('sqlite '+ FormatDateTime(' dd-mm-yyyy  hh-nn-ss', now)+'.db');
    SelectDirectory('Selezionare una cartella dove salvare il backup', '', Directory, True);
    If Directory = '' then MessageBox('Non è stata selezionata nessuna cartella. Nessun backup salvato!','Error',MB_OK+MB_ICONWARNING)
      else
      Begin
        CopyFile(Form1.Label9.Caption,Directory+'\'+FileName);
        MessageBox('Il backup è stato salvato con successo!','Backup completato',MB_OK+MB_ICONINFORMATION)
      End;
end;

end;
Domebil

Re: code no longer working in the latest version

Please attach your project and describe the problem in more details.


Why you use TStringList class for ini files?


There is special class to work with ini files, an example:


How to read values

procedure Form1_OnShow (Sender: string; Action: string);
var
    ini: TIniFile;
begin
    ini := TIniFile.Create(ExtractFilePath(Application.ExeName)+'myapp.ini');
    try
        Form1.Edit1.Text := ini.ReadString('Settings', 'Edit1', '');
        Form1.Edit2.Text := ini.ReadString('Settings', 'Edit2', '');
    finally
        ini.Free;
    end;
end;

Project with the example:
http://myvisualdatabase.com/forum/misc. … download=1

Dmitry.

Re: code no longer working in the latest version

I have to backup the entire database remotely

Domebil