Hi there everyone,
I'm having some trouble with sending a variable to a modal form, modifying the variable and then acting on the value of the modified variable.
I send a variable ACancelOperation (among others) to a modal form. Initially the value of ACancelOperation is 'No'. If the user clicks the "Close" button on the modal form; the FCancelOperation in the form is set to 'Yes'. The code is as shown below:
procedure TfrmServer.acParametersExecute(Sender: TObject);
{ Displays the server parameters form which updates the configuration file }
var
ParametersForm: TfrmParameters;
ACancelOperation: string;
begin
// Initialize the ACancelOperation variable
ACancelOperation := 'No';
// Create the parameters form
Application.CreateForm(TfrmParameters, ParametersForm);
// Send the port number and the number of maximum connections to the parameters form
ParametersForm.GetParameters(FPort, FMaxConnections, FOneConnectionPerClient, ACancelOperation);
try
// Display the form modally
ParametersForm.ShowModal;
finally
// Free the parameters form
ParametersForm.Free;
end;
// Make the restart label visible if the user clicked on the Close button in the Parameters form
if ACancelOperation = 'No' then
lblRestart.Visible := True;
end;
The code in the Parameters form is shown below:
procedure TfrmParameters.GetParameters(APort, AMaxConnections, AOneConnectionPerClient: string; var ACancelOperation: string);
begin
FPort := APort;
FMaxConnections := AMaxConnections;
FOneConnectionPerClient := AOneConnectionPerClient;
FCancelOperation := ACancelOperation;
end;
procedure TfrmParameters.bbtnCloseClick(Sender: TObject);
begin
//
FCancelOperation := 'Yes';
end;
By the way, I tried
a) using "var" attempting to pass the ACancelOperation parameter by reference
b) using a boolean variable
Neither (a) nor (b) worked!

What am I doing wrong?
JD