How do I make a procedure in one form wait for a value from another form? lazarus / 21-General ---------------------------------------------------------------------- OC DelGuy · 2021-01-17 07:45 I created two forms.  I click in form1 to get two numbers from form2. I start with this: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.FormActivate(Sender: TObject);begin  Form2.Enabled:=FALSE;  Form2.Visible:=FALSE;end; // End TForm1.FormActivate(Sender: TObject) So, just to make sure, In form1 I hide and disable form2 during form1 activation. In form1 I have a TListBox with 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.ListBox1Click(Sender: TObject);        Form2.Enabled:=TRUE;      Form2.Visible:=TRUE; I enable and make visible form2 which has a TSpinEdit. The very next line is: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     While Form2.Visible Do; My intent is for form 1 to stop and wait (by looping around) for me to spin to the correct number in form2 and then in form2 I have a procedure: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 TForm2.Button1Click(Sender: TObject);begin  Number := SpinList1.Value+2;  Form2.Visible:=FALSE;end;  Now it isn't visible so it's false and the procedure in form1 should continue.  But not before I click the button in form2. Now, the problem is that I think the While loop is running, but the procedure continues with the code AFTER the While loop even though form2 is still visible.  As long as Form2 is visible, the While loop should be... ... Looping!  And not continuing past the While loop. Shouldn't it? Or is there something that makes 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 Form2.Visible false even though during runtime, I can see it! ---------------------------------------------------------------------- SudoKai · 2021-01-17 08:14 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  //Form2.Visible := True; Form2.ShowModal;  //Form2.Visible := False; Form2.Close; ---------------------------------------------------------------------- OC DelGuy · 2021-01-17 08:26 Quote from: SudoKai on January 17, 2021, 09:14:45 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  //Form2.Visible := True; Form2.ShowModal;  //Form2.Visible := False; Form2.Close; I'm a beginner.  I do not understand your reply. ---------------------------------------------------------------------- SudoKai · 2021-01-17 08:40 To make a form visible and wait for a response you can use ShowModal To close (or hide) a form you can use Close 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.ListBox1Click(Sender: TObject);        Form2.ShowModal; 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 TForm2.Button1Click(Sender: TObject);begin  Number := SpinList1.Value+2;  Form2.Close;end; ---------------------------------------------------------------------- MarkMLl · 2021-01-17 09:40 This is a bit of arcane terminology that goes back to Xerox PARC in the 70s. A modal form is one that has to be interacted with and closed before its caller continues, basically like a custom dialog(ue) box. MarkMLl ---------------------------------------------------------------------- OC DelGuy · 2021-01-24 06:09 Quote from: SudoKai on January 17, 2021, 09:40:52 amTo make a form visible and wait for a response you can use ShowModal To close (or hide) a form you can use Close 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.ListBox1Click(Sender: TObject);        Form2.ShowModal; 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 TForm2.Button1Click(Sender: TObject);begin  Number := SpinList1.Value+2;  Form2.Close;end; Thanks!  this worked!