On this page Attributes of buttons and keys
|
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.
Release 6 enhancement - ActionEx
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.
The attributes of a Variable determine its nature and behaviour. Some of the widely used attributes are discussed below:
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.
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.
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.
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.
Syntax
[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.
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 can be broadly classified as follows:
● Local
● Global
● 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.
Note: A Global variable can also be made local to a Report by associating it to a Report, as discussed in Local variables above.
Syntax
[System: Variable]
Variable : < Initial Type Based V alue>
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.
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.
Note: The Variables used in a Field Acting as a Variable are local variables, and are local to the Report.
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.
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.
The following code snippet explains the usage of Local variable.
[Variable : LocVar]
Type : String
Default : "This is the default value"
;; Variable LocVar of Type String is defined and it is assigned a Default Value
[Report : Local Variable]
Variable : LocVar
;; At this point, Variable LocVar becomes a Local Variable for this Report
[Field : Local Variable Field]
Set As : "This is a Local Variable in Report"
Modifies : LocVar
;; Here, the variable value is modified with the Field contents specified in ‘Set As’
In this code snippet, a local variable LocVar is defined and locally attached to the Report ‘Local Variable’. This Report modifies the Variable Value to ‘This is a Local Variable in Report’. Once we exit from this Report, the value of the variable locvar modified in this Report is lost.
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.
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”
This attribute is used to give a unique key combination, which can be activated by pressing the same from any Report or Menu. This attribute is mandatory if action is specified in this definition.
Syntax
[Key/Button : <Key/Button Name>]
Key : <Combination of Keys>
Example
[Button: NonColumnar]
Key : Alt + F5
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
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 : <Logical Condition>
Example
[Button: Close Company]
Inactive : $$SelectedCmps < 1
The attribute ActionEx is used to enhance the multi-action support at button or key level. It allows you to specify multiple actions for executions when you invoke a key or button. ActionEx is a triple list attribute.
Syntax
[Button:<Button Name>]
ActionEx: <Label>:<Action Keyword>[:<Action Parameters>]
OR
[Button :<Button Name>]
<Label>:<Action Keyword>[:<Action Parameters>]
Where,
<Button Name> is the name of the button definition.
<Label> is any string to identify the ActionEx statement. Label supports for deletion, addition, modification, and replacement of the ActionEx statements. It is a mandatory sub-attribute.
● If the labels are unique, every ActionEx statements are executed in the order of their specifications.
● If the labels are same, the last action within the same label is executed.
<Action Keyword> is any platform or object specific action except the function specific actions.
<Action Parameters> List of parameters as required by the action specified, separated by colon. Depending on the specified action keyword this parameter can be optional.
Example: 1
[Button: Show Final Accounts]
Key : Ctrl + F
ActionEx: TB : Display : Trial Balance
ActionEx: PL : Display : Profit and Loss
ActionEx: BS : Display : Balance Sheet
OR
[Button: Show Final Accounts]
Key : Ctrl + F
TB : Display : Trial Balance
PL : Display : Profit and Loss
BS : Display : Balance Sheet
Example: 2
Modify the code in example 1 to display the modified final accounts as given below:
● Delete the action to display TrialBalance using the attribute Delete: TB.
● Add the action to set the attribute ExplodeFlag as yes, after the label PL.
● Modify BS label to display the report 'MyBalanceSheet'.
[Button: Modified Final Accounts]
Use : Show Final Accounts
Delete : TB
Add : ActionEx: After:PL: ExplodeFlagNo : Set: ExplodeFlag: No
Replace : ActionEx: BS :BS: Display : My Balance Sheet
[Report: My Balance Sheet]
......
Form: Balance Sheet
Example: 3
Use the button Show Final Accounts mentioned in Example 1, in the report MyReport and modify it locally to delete the display of Trial Balance using ActionEx.
[Report: My Report]
......
Form: My Report
[Form: My Report]
....
Button: Show Final Accounts
Local : Button: Show Final Accounts: Delete: ActionEx: TB
You can use the attribute ActioEx to achieve multi-action support which reduces the code size, instead of the attribute Action List with additional key definitions.
To display the final accounts using a button you need to write the following code using the attribute Action List.
Example
[Button: Show Final Accounts]
Key : Ctrl + F
Action List : Show Trial Balance, Show Profit and Loss, Show Balance Sheet
;; Key Names which are to be triggered in sequence
[Button: Show Trial Balance]
Key : Ctrl + F
Action : Display : Trial Balance
[Button: Show Profit and Loss]
Key : Ctrl + F
Action : Display : Profit and Loss
[Button: Show Balance sheet]
Key : Ctrl + F
Action : Display : Balance Sheet
Whereas when you use the attribute ActionEx, it reduces the code size.
Example:
[Button: Show Final Accounts]
Key : Ctrl + F
ActionEx: TrialBalance : Display : Trial Balance
ActionEx: ProfitandLoss : Display : Profit and Loss
ActionEx: BalanceSheet : Display : Balance Sheet
What is the order of execution when ActionEx is specified with unique labels?
When ActionEx is specified with unique labels, the order of execution is same as the order of specification.
Example
[Button: Show Final Accounts]
Key : Ctrl + F
Title : Final Accounts
ActionEx: TB : Display : Trial Balance
ActionEx: PL : Display : Profit and Loss
ActionEx: BS : Display : Balance Sheet
In the above example, the button Final Accounts displays the reports in the given order Trial Balance, Profit and Loss, and Balance Sheet.
What is the order of execution when multiple instances of ActionEx are specified with the same label?
When multiple instances of ActionEx are specified with the same label name, then only the action specified in the last label occurrence will get executed.
Example
[Button: Show Final Accounts]
Key : Ctrl + F
Title : Final Accounts
ActionEx: TB: Display : Trial Balance
ActionEx: PL: Display : Profit and Loss
ActionEx: TB: Display : Balance Sheet
In the above example, the button Final Accounts displays the report Balance Sheet first and then the report Profit and Loss. It ignores the report Trial Balance.
I have used the attributes Action List, Action, and ActionEx in my project. What is the order of execution for these actions?
When you use these attributes together in your button definition, in any combination, the order of priority for actions is as given below:
1. Action List
2. ActionEx
3. Action
It executes only the highest priority action statement and other action statements are ignored. Refer the following table to understand more about the order of execution.
Attributes Specified |
Executed |
Ignored |
Action, Action List, and ActionEx |
Action List |
Action and ActionEx |
Action List and ActionEx |
Action List |
ActionEx |
Action List and Action |
Action List |
Action |
Action Ex and Action |
ActionEx |
Action |
Learning Outcome
● A variable is a storage location or an entity. It is a value that can change, depending either on the conditions or on the information passed on to the program.
● The Variable attribute Type determines the Type of value that will be held within it.
● The attribute Default is used to assign a default value to a variable, based on the Type defined.
● The attribute Persistent decides the retention periodicity of the attribute.
● The attribute Modifies in a Field definition is used to modify the value of a variable.
● Title, Key, Action, ActionEx, and Inactive are the attributes of button definition.