Download Free Tools for Tally ERP
FREE utilities for Tally Accounting Software

Tuesday, February 13, 2007

Example 7: Local and Global Variables

Local Variables
The scope of Local variables is restricted to the Report in which they are defined. Before you can use a local variable, you need to define it. To access the value of a local variable, you must prefix the variable name with symbol #



Local Variable definition
[Variable: myVar]
Type: String



Using the Local variable in your Report
[Report: My Report]
Form: MyForm
Variable: myVar
Set as: "Learn TDL at www.tdlplayground.blogspot.com"



Accessing the Local Variable value
[Field: My Field]
Set as: #myVar



Global Variables
Global variables can be used globally (i.e. in all Reports). A Global variable must be declared in the [System: Variable] section. To access a Global variable, you must prefix the variable name with ##.



Global Variable definition
[System: Variable]
myVar: "Initial Value"



Accessing the Global Variable value
[Field: My Field]
Set as: ##myVar



Other Variable types supported by Tally
1) Logical
2) Date
3) Number
4) Amount
5) Quantity
6) String
7) Rate of Exchange

A sample TDL program (with source-code) has been provided which illustrates the use of Variables. Click here to download the Example 7 compiled file and the source-code.
Tally; Tally Developer and Tally Definition Language are trademarks or registered trademarks of "Tally Solutions", Bangalore.