Variables,
Buttons and Keys
Introduction
A Variable is
a storage location or an entity.
It is a value that can change,
depending on the conditions or on the information passed to the program.
The actions in TDL can be delivered in three ways: by activating a Menu Item,
by pressing a Key or by activating a Button. The definitions of
both Buttons and Keys are the same, but at the time of deployment, Keys differ
from Buttons.
Variable
In TDL, a
Variable is one of the important definitions, since it helps to control the
behaviour of Reports and their contents.
Variables assume different values during execution and these values
affect the behaviour of the Reports.
A Variable definition is similar to any other definition.
Syntax [Variable : Variable Name]
Attribute : Value A Variable should be
given a meaningful name which determines its purpose.
Attributes
of a Variable
The attributes of a Variable determine its nature and
behaviour. Some of
the widely used attributes are discussed below: Type This attribute
determines the Type of the value that will be held by the variable. The Types
of values that a variable can handle are String, Logical, Date and Number. In the absence of this
attribute, a variable assumes to be of the Type String, by default.
Syntax [Variable : Variable Name]
Type : Data
Type
Example: [Variable : ICFG Supplementary]
Type : Logical
A logical variable ICFG Supplementary is defined and
used to control the behaviour of certain reports, based on its logical value,
as configured by the user.
Default
This attribute is used to assign a default value to a
variable, based on
the ‘Type’ defined.
Syntax
[Variable : Variable Name]
Default : Initial Value
Value of the variable should adhere to the data type
specified with ‘Type’ Attribute.
Example: [Variable :
DSP HasColumnTotal]
Type : Logical Default : Yes
The Default Initial Value for the logical Variable DSP
HasColumnTotal is set to YES. This variable will begin with an initial
value YES in the Reports, unless overridden by the System Formula. We will
learn about the System Formula in the coming sections.
Persistent
This attribute decides the retention periodicity of the attribute. If the attribute ‘Persistent’ is set to YES, then the latest value of the variable will be retained across the sessions, provided the variable is not a local variable. We will learn about the concept of local and global variables shortly. Syntax [Variable : Variable Name]
This attribute decides the retention periodicity of the attribute. If the attribute ‘Persistent’ is set to YES, then the latest value of the variable will be retained across the sessions, provided the variable is not a local variable. We will learn about the concept of local and global variables shortly. Syntax [Variable : Variable Name]
Persistent :
Logical Value
Example: [Variable :
SV Backup Path]
Type : String Persistent : Yes
The attribute ‘Persistent’ of the variable SV Backup Path
has been set to YES, which means that it retains the latest path given by the
user even during the concurrent sessions of Tally.
Volatile
In cases where
the ‘Volatile’ attribute in the Variable definition is set to YES, the variable
is capable of retaining multiple values, i.e.,
its original value with its subsequent values, are stored as a stack.
The default value of this attribute is YES. In cases where a new report R2 is
initiated, using a volatile variable V,
from the current report R1,
the current value of the volatile variable will be saved as in a stack,
and the variable can assume a new value in the new report R2. Once the previous report
R1 is returned back from the report R2, the previous value of the variable will
be restored. A classic example of this is a drill-down Trial Balance.
SyntaxVariable,
[Variable
: Variable Name]
Volatile
: Logical Value
Example:
[Variable
: GroupName]
Type : String Volatile : Yes
The ‘Volatile’ attribute of Group Name Variable is
set to YES, which
means that the variable ‘Group Name’ can store multiple values, which have been
received from multiple reports.
Repeat
This attribute is mainly used to achieve the Auto Column behaviour in various Reports. Each Column is created with a subsequent Object in a Collection automatically, till all the columns required for Auto Columns exhaust. The ‘Repeat’ attribute has its value as a variable which has the collection of Objects, for which the columns need to be generated. Every time the Repeat is executed, the column for the subsequent Object is added.
This attribute is mainly used to achieve the Auto Column behaviour in various Reports. Each Column is created with a subsequent Object in a Collection automatically, till all the columns required for Auto Columns exhaust. The ‘Repeat’ attribute has its value as a variable which has the collection of Objects, for which the columns need to be generated. Every time the Repeat is executed, the column for the subsequent Object is added.
Syntax
[Variable : Variable Name]
Repeat : Variable Value
Example: [Variable : SV FromDate]
Type : Date
Volatile : Yes
Repeat :
##DSPRepeatCollection
##DSPRepeatCollection Variable receives the
Collection Name from a Child Report, which accepts inputs from the user
regarding the columns required. Variable SVFromDate gets repeated over
the subsequent period in the Collection each time the column repeats.
The Scope of a Variable
The scope of a Variable can be broadly classified as
follows:
p Local
p Global
p Field acting as a variable
Local
A Variable is termed as a local variable when it is
associated to a Report. This means that the scope of the variable covers only
the current report and its components. It is not mandatory for local variables
to have an initial value. Syntax [Report : Report Name]
Variable : Variable
Name
Example: [Report :
Balance Sheet]
Variable : Explode Flag
Explode Flag Variable is made local to the Report
‘Balance Sheet’ by associating it using the Report attribute ‘Variable’.This
variable retains its value as long as we work with this Report. On exiting the
Report, the original value if given, is returned and the value modified within
this report is lost. For example, consider a situation where ‘Stock Summary’
Report is being viewed with Opening, Inwards, Outwards and Closing Columns
enabled through Configuration settings. Once we quit this Report and re-enter
the Report, the variables return to the default settings.
Global A variable is termed as Global variable when
it is defined under System Variable section. It means that the scope of the
variable covers all reports. An initial value is mandatory for global
variables.
Syntax [System
: Variable]
Variable
: Initial Type Based Value
Example: [System : Variable]
BSVerticalFlag : No
The BSVerticalFlag
Variable is made Global. Hence, this variable value being modified in a
Report is retained, even after we quit and re-enter the Report. The retention
of a Global Variable can be done on two levels, i.e., either within the current
session or across the sessions. If the Variable attribute ‘Persistent’ is set
to YES, then the modified variable value is retained across the sessions, else
the value defaults back to initial value on re-entering
another session of Tally.
Field Acting as a Variable
The Variable attribute in a ‘Field’ Definition is used to make the Field behave as a Variable. when value is entered/altered in a Field, the variable assumes the same value with immediate effect. The Variable need not be defined previously, since it inherits its data type from the Field itself. For example, in a Trial Balance Report, which is a drill down report, there is a need to retain the Group Name which has been selected by the user. So, each time the user scrolls up and down, the field value changes and the current field value is passed on to the variable immediately, so that if the current group is selected and drilled down, the report begins with the sub groups and ledgers of the selected group.
The Variable attribute in a ‘Field’ Definition is used to make the Field behave as a Variable. when value is entered/altered in a Field, the variable assumes the same value with immediate effect. The Variable need not be defined previously, since it inherits its data type from the Field itself. For example, in a Trial Balance Report, which is a drill down report, there is a need to retain the Group Name which has been selected by the user. So, each time the user scrolls up and down, the field value changes and the current field value is passed on to the variable immediately, so that if the current group is selected and drilled down, the report begins with the sub groups and ledgers of the selected group.
Syntax
[Field : Field Name]
Variable : Variable Name
Example: [!Field : DSP Group Acc]
Variable :
Group Name
This is used
in the ‘List of Accounts’ Report in Tally.ERP 9, wherein
the optional Field DSP Group Acc is made to act as a variable by using the
Field attribute ‘Variable’, and the value selected by the user is passed on to
this variable for further use.
Modifying the Variable Value
A Field attribute Modifies is used to modify the
value of a variable.
Syntax [Field : Field Name]
Modifies : Variable
Name
Example:
[Field
: SLedger]
Modifies : SLedger
The SLedger Variable is modified with the value stored/keyed
in the Field SLedger.
Buttons and Keys
The actions in TDL can be delivered in three ways - by activating a Menu
Item, by pressing a Key or by activating a Button.
The definition of both Buttons and Keys are the same, but at the time of
deployment, Keys differ from Buttons. All the Buttons used within the attribute
‘Buttons’ are visible on the button bar,
so that the user can either click it or press the unique key
combination. All the Buttons used within the attribute ‘Keys’ are invisible
entities and the key combination associated in the Key must be pressed to
activate a key; whereas to activate a button, either it can be clicked or the
key combination assigned for the button can be pressed
Attributes
of Buttons/Keys
Title The ‘Title’ attribute can be used to give a
meaningful Title to the Button being displayed on the Button Bar. This attribute is
optional.
Syntax
[Key/Button : Key/Button Name]
Title : Button
Title
Example: [Button : NonColumnar]
Title : “No Columns”
Action The Action attribute is used to
associate an Action with the Button. Every Button or Key is defined for the
purpose of executing certain predefined actions.
Syntax [Key/Button : Key/Button Name]
Action : Required
Action
Example: [Button :
NonColumnar]
Action : Set : ColumnarDayBook : NOT ##ColumnarDayBook
In case
the Title is not specified, then by default, it assumes the Button Name as its title. In
cases where it is
used as a Key, the
Title is ignored, since the Keys are hidden in a Menu or a Report.
Inactive The Inactive attribute is used to activate
the Button, based on some condition.
If the condition is FALSE, the button will be displayed, but it cannot
be activated.
Syntax [Key/Button : Key/Button
Name]
Inactive :
Example:
[Button
: Close Company]
Inactive : $$SelectedCmps < 1
Skip to main content