Recent

Author Topic: howto push variable values from Form2 to Form1  (Read 3626 times)

ensimek

  • Jr. Member
  • **
  • Posts: 55
howto push variable values from Form2 to Form1
« on: June 18, 2010, 01:06:52 pm »
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

  • Hero Member
  • *****
  • Posts: 521
Re: howto push variable values from Form2 to Form1
« Reply #1 on: June 18, 2010, 02:26:04 pm »
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: [Select]
implementation
 uses  form2;  // to access "myfrm2"
...

 if  myfrm2.var1 > myfrm2.var2 then ...
..
windows 7/10 - laz 2.0 / 1.2.6 general releases

 

TinyPortal © 2005-2018