Settings are saved from Memo, but only the first row of the 3 saved is loaded. What am I doing wrong ?

procedure T_Main.Button1Click(Sender: TObject); var Ini: Tinifile; begin Ini := TiniFile.Create(extractfilepath(paramstr(0))+'Setting.ini'); Ini.WriteString('settings_p','T1', Memo1.Lines[0]); //сохраняСм Π² ΠΈΠ½ΠΈ Ini.WriteString('settings_p','T2', Memo1.Lines[1]); //сохраняСм Π² ΠΈΠ½ΠΈ Ini.WriteString('settings_p','T3', Memo1.Lines[2]); //сохраняСм Π² ΠΈΠ½ΠΈ Ini.Free; end; procedure T_Main.Button2Click(Sender: TObject); var Ini: Tinifile; begin Ini := TiniFile.Create(extractfilepath(paramstr(0))+'Setting.ini'); Memo1.Lines[0] := Ini.ReadString('settings_p','T1',Memo1.Lines[0]); //Π·Π°Π³Ρ€ΡƒΠΆΠ°Π΅ΠΌ ΠΈΠ· ΠΈΠ½ΠΈ Memo1.Lines[1] := Ini.ReadString('settings_p','T2',Memo1.Lines[1]); //Π·Π°Π³Ρ€ΡƒΠΆΠ°Π΅ΠΌ ΠΈΠ· ΠΈΠ½ΠΈ Memo1.Lines[2] := Ini.ReadString('settings_p','T3',Memo1.Lines[2]); //Π·Π°Π³Ρ€ΡƒΠΆΠ°Π΅ΠΌ ΠΈΠ· ΠΈΠ½ΠΈ Ini.Free; end; 
  • Hello Tatiana. And in Memo1 how many lines at the time of the call to Button2Click ? How did you determine that the lines are not loading? - Igor
  • Igor, Hello. Corrected the issue. It turns out that only the first row of the 3 saved is loaded. Memo is empty at the time of the call. - Tatiana
  • one
    Tatiana, please learn how to properly format the code so that there is no vinaigrette from indents .. - Kromster
  • Kromster, Note accepted. In the future, this rule will be observed. - Tatiana

1 answer 1

 procedure T_Main.Button2Click(Sender: TObject); var Ini: TIniFile; begin Ini := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'Setting.ini'); try Memo1.Lines.Clear; Memo1.Lines.Add(Ini.ReadString('settings_p', 'T1', ''); //Π·Π°Π³Ρ€ΡƒΠΆΠ°Π΅ΠΌ ΠΈΠ· ΠΈΠ½ΠΈ Memo1.Lines.Add(Ini.ReadString('settings_p', 'T2', ''); //Π·Π°Π³Ρ€ΡƒΠΆΠ°Π΅ΠΌ ΠΈΠ· ΠΈΠ½ΠΈ Memo1.Lines.Add(Ini.ReadString('settings_p', 'T3', ''); //Π·Π°Π³Ρ€ΡƒΠΆΠ°Π΅ΠΌ ΠΈΠ· ΠΈΠ½ΠΈ finally Ini.Free; end; end; 
  • Now it works fine. I am by the way about cleaning Memo1.Lines.Clear; I didn’t think of anything either. Although I knew about it. Igor, As always, thank you very much. - Tatyana