Answer the question
In order to leave comments, you need to log in
How to save form content in ini file?
There is a memo on the form, you need to save the contents of the memo to the INI file, but do it through the SaveDialog with the given name. Then open this or another ini using OpenDialog.
Answer the question
In order to leave comments, you need to log in
Since there are many descriptions on the network, I will give the first one in Russian: TIniFile or Working with INI files in the same place.
Since the ini file is not just text, but a structure, loops are needed.
const
siSection = 'Memo';
siCount = 'Count';
siLine = 'Line';
…
var f: TIniFile; i: Integer;
begin
if SaveDialog1.Execute then begin
f := TIniFile.Create( SaveDialog1.FileName );
f.WriteInteger( siSection, siCount, Memo1.Lines.Count );
for i:= 1 to Memo1.Lines.Count
do f.WriteString( siSection, siLine + IntToStr(i), Memo1.Lines[i-1] );
f.Free;
end;
end;
…
var f: TIniFile; i: Integer;
begin
if OpenDialog1.Execute then begin
f := TIniFile.Create( OpenDialog1.FileName );
Memo2.Lines.Clear;
for i:= 1 to f.ReadInteger( siSection, siCount, 1 )
do Memo2.Lines.Add( f.ReadString( siSection, siLine + IntToStr(i), '' ));
f.Free;
end;
end;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question