Board index » delphi » Declaring a var that a whole program uses?

Declaring a var that a whole program uses?

How can i use a variable during the whole program and not just during a
unit.
I want to know how more units can use the same var.
If u know the sollution then please mail me.
Thank u

 

Re:Declaring a var that a whole program uses?


Quote
Alexander Muylaert wrote:

> How can i use a variable during the whole program and not just during a
> unit.
> I want to know how more units can use the same var.
> If u know the sollution then please mail me.
> Thank u

Declare the variable in the interface section of a unit, then add
that unit's name to the uses clause of the unit you want to access it
from.

Joe
--
Joe C. Hecht
Borland Delphi Developer Support Group
Technical Documents and Online Forums are available at
http://www.borland.com

Re:Declaring a var that a whole program uses?


put it in the main form for your application and be sure all other forms
have the main unit in a uses clause under the IMPLEMENTATION section (not
the program command where all the other uses clauses are).

-D

In article <01bc2a48$251b0170$4e0407c2@mga>, muylaert.alexan...@khk.be
says...

Quote

>How can i use a variable during the whole program and not just during a
>unit.
>I want to know how more units can use the same var.
>If u know the sollution then please mail me.
>Thank u

--
-------------------------------------------------------
Pacifier Online Data Service Dialup SLIP/PPP User
To register: (360) 693-0325 or telnet pods.pacifier.com
-------------------------------------------------------

Re:Declaring a var that a whole program uses?


If you have lots of this you can create a unit with only one purpose and that is to have global variables.
Just put them under the public part and include this unit in all units that need to use it.

johan

Other Threads