How do I get procedure to pause and actually show the form? lazarus / 21-General ---------------------------------------------------------------------- OC DelGuy · 2025-04-11 04:08 When I run this procedure, it works fine. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure TForm1.ReadRecords;  Var    F: TextFile;    Line: string;    x, y : SmallInt;  Begin    If not FileExists(FileName) Then      Begin      ShowMessage('File does not exist.');      End    Else      Begin      AssignFile(F, FileName);        Directions.Clear;        Reset(F);      TemFile := TStringList.Create;        For x:=1 to 1000 Do MemFile[x] := TStringList.Create;        x := 0;  y := 1;        While not EOF(F) Do          Begin            ReadLn(F, Line);  Line := Trim(Line);  TemFile.Insert(0,Line);  // Read the file line by line. File reversed.            Directions.Lines.Add( IntToStr(TemFile.Count) + '.   ' + Temfile[0]);          End;        CloseFile(F);      End;    Temfile.Free;  End;  But if I add the following: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure TForm1.ReadRecords;    While TemFile.Count > 1 Do         // StringList still has strings      Begin        Directions.Lines.Add('In the While Loop.');    // Yes, I realize this is an endless loop.        Application.ProcessMessages;      End;        // While TemFile.Count > 1 Do  This runs, but, the form never shows: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure TForm1.ReadRecords;  Var    F: TextFile;    Line: string;    x, y : SmallInt;  Begin    If not FileExists(FileName) Then      Begin      ShowMessage('File does not exist.');      End    Else      Begin      AssignFile(F, FileName);        Directions.Clear;        Reset(F);      TemFile := TStringList.Create;        For x:=1 to 1000 Do MemFile[x] := TStringList.Create;        x := 0;  y := 1;        While not EOF(F) Do          Begin            ReadLn(F, Line);  Line := Trim(Line);  TemFile.Insert(0,Line);  // Read the file line by line. File reversed.            Directions.Lines.Add( IntToStr(TemFile.Count) + '.   ' + Temfile[0]);          End;        CloseFile(F);      End;    While TemFile.Count > 1 Do         // StringList still has strings      Begin        Directions.Lines.Add('In the While Loop.');    // Yes, I realize this is an endless loop.        Application.ProcessMessages;      End;        // While TemFile.Count > 1 Do    Temfile.Free;  End;  How do I make it so that when the While TemFile.Count > 1 Do is running, the form actually shows? ---------------------------------------------------------------------- Fibonacci · 2025-04-11 04:29 But why? It will keep running forever. You dont delete anything from TemFile. If you fix that, you wont need Application.ProcessMessages. Also, I suggest you just do LoadFromFile to your TStringList, then loop from TStringList.Count-1 downto 0, instead of doing Insert-s into index 0 of TemFile. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var  lines: TStringList;  i: integer;begin  lines := TStringList.Create;  try    lines.LoadFromFile(FileName);     for i := lines.Count-1 downto 0 do begin      Memo1.Lines.Add('line '+IntToStr(i)+': '+lines[i]);    end;  finally    lines.Free;  end;end; ---------------------------------------------------------------------- TRon · 2025-04-11 05:03 Quote from: OC DelGuy on April 11, 2025, 06:08:39 amHow do I make it so that when the While TemFile.Count > 1 Do is running, the form actually shows? By showing the form first, then perform the operation.