title: How to save to an INI file delphi
body: <p>I have buttons which when clicked store their caption in a TStringList</p>
  
  <pre><code>ChairList : TStringList;
  
  procedure TForm1.FormCreate(Sender: TObject);
  begin
  ChairList := TStringList.Create;
  end;
  </code></pre>
  
  <p>An example of one button is:</p>
  
  <pre><code>procedure TForm1.Table17Click(Sender: TObject);
  begin
  Label1.Visible := false;
  if (BottomPanel.Visible = false) then
  begin
    Label1.Visible := true;
  
    LastClicked := 'Table 17';
    ChairList.Add(LastClicked);
  </code></pre>
  
  <p>But when I read the file I get no result back. I tested it by using a <code>ShowMessage</code> just to see if anything would be read and I just get a blank <code>ShowMessage</code></p>
  
  <p>The following code is the save procedure:</p>
  
  <pre><code>Procedure TForm1.SaveToFile(Const Filename : String);
  Var
  INI : TMemIniFile;
  
  Procedure SaveReserve();
  var
  section : String;
  
  Begin
    Section := 'Table';
    ini.writeString(Section, 'LastClickedID', LastClicked);
  End;
  
  begin
  Ini := Tmeminifile.Create(filename);
  ini.Clear;
  try
  SaveReserve();
  Ini.UpdateFile;
  finally
  Ini.Free;
  end;
  end;
  </code></pre>
  
  <p>Then the next Procedure is the load file:</p>
  
  <pre><code>Procedure TForm1.LoadFile(const Filename : String);
  var
  INI : TMemInifile;
  Sections : TStringList;
  i : Integer;
  LastClickedID : String;
  Procedure LoadChair(Const Section: String);
  Begin
    LastClickedID := INI.ReadString(Section, 'LastClickedID', LastClicked)
  End;
  
  Begin
  ChairList.Clear;
  
  INI := TMEMINIFILE.Create(Filename);
   Try
   Sections := TStringList.Create;
   Try
     Ini.ReadSections(Sections);
     for i := 0 to (Sections.Count - 1) do
     Begin
       if startstext('LastClickedID', Sections[I]) then
        begin
          LastClickedID := (copy(Sections[I], 12, MaxInt));
  
        end;
     End;
   Finally
    Sections.Free;
   End;
   Finally
   INI.Free;
  end;
  ShowTable(LastClickedID);
  end;
  
  ShowTable(LastClickedID); is just the part where i test it
  </code></pre>
  
  <p>How can i make it so it saves the caption and then when i load it up it shows any table caption saved?
  I only need it to save the caption of an object selected. When the user selects a button it adds the caption to the stringlist which is then read to the ini file </p>