How To pass parameters between objects (forms, reports, ...)?Author: Luc Van Dyck
This example uses 2 forms:
- Form1 asks for a name and two decimal values
- After clicking the "Call Form2" button, these variables are passed to
Form2, where they are displayed.
- After clicking the "Return to Form1" button, focus is placed again on
Form1 and the result of the calculation (decimal1 + decimal2) is displayed.
This is the code behind the "Call Form2" button of Form1. Form2 is defined as a
variable (frmForm2), otherwise it isn't possible to call the functions on that form.
OnPush()
CLEAR(frmForm2);
frmForm2.fctSetName(txtName);
frmForm2.fctSetDecimal1(decNumber1);
frmForm2.fctSetDecimal2(decNumber2);
decResult := 0;
IF frmForm2.RUNMODAL = ACTION::Close THEN BEGIN
decResult := frmForm2.fctGetResult;
END;
Here are the functions of Form2, which accepts the parameters and returns the result of the calculation. The
parameters are stored in global variables, so they can be used in the form.