Forum > General

howto push variable values from Form2 to Form1

(1/1)

ensimek:
Hi guys,
I've a few variables defined in main Form1

ex:
paperName:  string;
printerIndex: integer;

in Form2 (Configuration) I can change all of above and these are saved in ini file. How can I refresh Form1 variables while chaning them in Form2?

mas steindorff:
there are several ways to do this.
1. (the right way) is to move these variables into a 3rd unit but that's only if there are several and they may grow into an object.
2: declare them in the interface section of the file they live in.
3: just add then into the "public" section of the form's "TForm " def

however you do it, the other unit will need to "uses" this form (which form1 proably already does).
expamle with var living in the pubic

--- Code: ---implementation
 uses  form2;  // to access "myfrm2"
...

 if  myfrm2.var1 > myfrm2.var2 then ...
..

--- End code ---

Navigation

[0] Message Index

Go to full version