https://help.tallysolutions.com/docs/td9rel54/tdl_reference/symbols_and_prefixes.htm

Symbols and Prefixes

On this page

Access Specifiers

Usage of @ and @@

Usage of # and ##

Usage of $ and $$

Usage of ;, ;; and /**/

Usage of +

Exposing Methods (_)

Reinitialize Definitions (*)

Optional Definitions (!)

In the previous lesson, we discussed the various TDL Components like definitions, attributes, functions, symbol prefixes, variables, etc.

In TDL, there are a few symbols which are used for specific purposes. Some symbols are used as access specifiers, i.e., mainly used to access the value of a method, variable, field, formula, etc. Some are used for general purpose, such as modifiers.

Figure_3.1_Symbol_Categorization.jpg

Access Specifiers/Symbol Prefixes

Sym b ols

U sage

@

Used to access L ocal formula

@@

Used to get the value of a System formula

#

Gives the value of the field, when prefixed to Field name

##

Used to get the value of a Glo b al varia b le

$

Used to access t h e v a lue o f an Object Method

$$

Used to call a Function

General Symbols

Symbols

Usage

; ;; ;;; /* */

Used for adding commen t s in TDL

+

Used as line continuation character

_ (underscore)

Used to expose methods to ODBC SQL Procedure

*

Used to Reinitialize a Definition

!

Used to create an Optional Definition

#

Used as a definition modifier

The Usage of @ and @@

Formula

In TDL, large complex calculations can be broken down into smaller simple calculations or expressions expressed as a Formula. The values computed using these formulae can be accessed using the symbol prefixes @ and @@.

Naming Conventions for Formula

Case insensitive

Only alphanumeric characters are allowed

Space insensitive at Definition time. However, during deployment or usage of the same, spaces are not allowed

Classifications of formula

Local Formula

Global Formula

Defining a Local Formula using @

A Local Formula is one which can be defined and retrieved at any Interface Definition. The scope of the local formula is only within the current definition. A local formula is usually defined if the formula is specific to a definition and not required by any other definition.

The value of a Local Formula can be accessed by using the Symbol Prefix @.

Example

[Field : CompanyNameandAddress]

Set as : “Tally India Pvt Ltd, No 23 & 24, AMR Tech Park II, Hongasandra,Bangalore”

This code can also be written, using the Local Formula, as:

[Field : CompanyNameandAddress]

Company : “Tally India Pvt Ltd, ”

Address : “No 23 & 24, AMR Tech Park II, Hongasandra, ”

City    : “Bangalore”

Set as  : @Company + @Address + @City

Defining a Global Formula using @@

A Global Formula is one which, when defined once, is available globally. In other words, the Global Formula value can be accessed by all the Definitions. A Global formula is defined when a formula is required at many locations. The value of a Global Formula can be accessed using the Symbol Prefix @@. A Global Formula can also be referred to as a System Formula. All the Global Formulae must be defined within the [ System: Formula ] Definition.

Example

[System : Formula]

AmtWidth : 20

[Field : RepTitleAmt]

Width : @@AmtWidth

[Field : RepDetailAmt]

Width : @@AmtWidth

[Field : RepTotalAmt]

Width : @@AmtWidth

In this example, all the Fields assume the same width. If the width of the fields needs to be altered, a change is made only at the [System: Formula] Definition Section. This change will be applied to all the Fields, using the Global Formula AmtWidth .

The Usage of # and ##

In TDL, the Symbol Prefix # can be used for:

Referencing a field using #

Modifying the existing definitions using #

Referencing a Field using #

The Symbol Prefix # is used to retrieve the value from another Field.

Example

[Field : HW]

Set as : “Hello World”

[Field : HW1]

Set as : #HW

In t h is example, the value wit h in the Field ‘HW’ is being set t o the Field ‘HW1’. In oth e r wo r ds, t h e Field HW1 is set to “Hello W orld”, by using #H W .

Modifying existing Definitions using #

The Symbol Prefix # is also used to modify existing definitions. One can alter the attributes of the definition. For example, adding a new Field within a ‘Line’ definition.

Example

[#Menu : Gateway of Tally]

Add   : Key Item : Hello World: H : Display : HWReport

Title : “Tally Gateway”

[#Field : LedParticulars]

Width : 50

In this example, the existing Menu ‘Gateway of Tally’ (default Menu) has been altered to add the Item ‘Hello World’ and the Title of the Menu has been changed to ‘Tally Gateway’. The existing Field ‘LedParticulars’ has also been altered to set its attribute ‘Width’ to the value of 50.

Accessing value from a Variable using ##

As the name suggests, a Variable is a named container of data which can be altered as and when required. In TDL, Variables can be classified as Local and Global Variables. Local variables retain their value only within a particular Report. Global variables, on the other hand, retain their values throughout the session or permanently, based on the ‘Variable’ Definition. We will learn more about Variables later.

The value of a Variable can be accessed using the symbol prefix ##. Both Local and Global Variables can be retrieved using ##. Local variable is being checked for first. In cases where the Local Variable is not found, the Global Variable value is assumed.

Example

[Field : FGField]

Set as : ##RTitle

[Report : DBLedReport]

Title : if ##LedgerName = “ ” then “Daybook” else “Ledger Report”

The Usage of $ and $$

Accessing a Method using $

Any information from an Object can be extracted by using a Method or UDF. The $ Prefix is used to invoke or deploy the value from a Method or UDF of any Object, where the terms ‘Method’ and ‘Object’ are TDL-specific. This will be covered in greater depth in the sections to follow.

Context Fall Through for $

Check if it is an Internal method or UDF within the current object

User Defined Method

System Formula

Change the context to parent object and repeat the above steps

Example

[Field : My Field]

Set as : $Name

This code snippet displays the value of the method ‘Name’ of the associated object.

Calling an Internal Function using $$

In TDL, functions are i n- built and TDL Pro g rammers can make u se of the same. A fu n ction can accept zero or m ore argumen t s to perform a s pecific t ask on the argumen t s and return a valu e . While passing argumen t s to functi o ns, s p aces and special characters, except bracket () , a r e n ot allowed. If the function par a meter re q uires a n e xpression, it c an be enclosed within bracket (), so as to ret u rn the result of t h e ex p ression as a p aramet e r to the Function.

Example

[Field : Current Date]

Set as : $$MachineDate

[Field : Credit Amt]

Set as : if $$IsDr:$ClosingBalance then 0 else $ClosingBalance

[Field : StringPart Field]

Set as : $$StringPart($Email:Company:##SVCurrentCompany):0:5

Commenting a Code using ;, ;; and /**/

Commenting increases readability. In TDL, Comments can be given using symbol prefixes viz. ;, ;; and /* */. Symbol Prefix ; is used for Part line commenting, ;; is used for Single Line Commenting and /* */ is used for Multi Line Commenting. All the lines enclosed within /* and */ will be ignored by the TDL Interpreter as a comment.

A Single Semi-Colon (;) is allowed as a comment for single line commenting, but as a standard coding practice, it is recommended to use Double Semi-Colon (;;).

Example

/*

This code explains the usage of Multi-Line Commenting

as well as Single Line Commenting.

*/

;; Altering Menu ‘Gateway of Tally’

[#Menu : Gateway of Tally]

Add : Key Item : Comment : C : Display: Comment

;; Menu Item alteration ends here

Line Continuation Character (+)

A Line Continuation Character (+) is used to split a lengthy line into a number of shorter lines. By doing this, the programmer can see the entire line without scrolling to the left or right. This can also help in understanding and debugging the code faster.

Example

/*

This code explains the mechanism of breaking a line into Multiple Lines using + */

;; Altering Menu ‘Gateway of Tally’

[#Menu: Gateway of Tally]

Add : Key Item : Before : @@locQuit : LineCtn : C : Display : +

LineCtn : NOT $$IsEmpty:$$SelectedCmps

Note : When you concatenate strings using the operator + and the size of the resultant string exceeds 2048 bytes or characters, the operation using the line continuation character + terminates. In such cases, you can use the function $$SPrintf for concatenation.

Exposing Methods and Creating Procedures (_)

The Symbol Prefix (_) is used to expose Methods to ODBC. By prefixing _ to a Collection Name, it turns into a procedure which can be referenced externally by passing the parameter as a Variable.

Example

;; Exposing Methods within the Objects to ODBC

[#Object : Ledger]

_Difference : $ClosingBalance - $OpeningBalance

;; Creating Procedures to be referenced externally

[Collection : _LedBills]

Type     : Bills

Child of : #UName

SQLParms : UName

SQLValues: Bill No : $Name

SQLValues: Bill Date : $$String:$BillDate:UniversalDate

Reinitialize Definitions (*)

This is similar to operators such as ‘#’ (Modify) and ‘!’ (Option). When ‘*’ is used for an existing definition, all the attributes of the definition are overridden. This is very useful when there is a need to completely replace the existing definition content with a new code.

Example

[*Field : MyField]

Width  : 20% Page

Set as : “This Field has been reinitialized”

Optional Definitions (!)

The Symbol Prefix ! is used to define optional definitions. ‘Switch’ and ‘Option’ are attributes which can be used by various definitions like Menu, Form, Part, Line, Field, Collection, Button, Key, Import File and Import Object to provide a conditional result in TDL. However, they cannot be used with Report, Color, Style, Variable, System Formula, System Variable, System UDF, Border and Object definitions.

The attributes of the original definition are overridden by the attributes of the optional definition only if the Logical Condition is satisfied. In other words, if the Logical Condition returns TRUE, the attributes of the optional definition become a part of the original definition, else they are ignored, leaving the original definition intact.

Syntax

Option : <Optional Definition> : <Logical Condition>

Switch : Label : <Optional Definition> : <Logical Condition>

The difference between Switch and Option is that ‘Switch’ statements bearing the same label are executed till a satisfying condition is found. On the contrary, ‘Option’ executes all the Option statements matching the given conditions sequentially. Switch statements bearing different labels are similar to Option statements, as all Switch statements will be executed for the given conditions.

Example - Option

[Line : MFTBDetails]

Fields : MFTBName

Right Fields : MFTBDrAmt, MFTBCrAmt

Option : MFTBDtlsClsgG1000 : $ClosingBalance > 1000

Option : MFTBDtlsClsgL1000 : $ClosingBalance < 1000

[!Line : MFTBDtlsClsgG1000]

Local : Field : MFTBDrAmt : Style : Normal Bold

Local : Field : MFTBCrAmt : Style : Normal Bold

[!Line : MFTBDtlsClsgL1000]

Local : Field : MFTBDrAmt : Style : Normal

Local : Field : MFTBCrAmt : Style : Normal

In this code snippet, the condition specified in both the options will be checked, and the option satisfying the given condition will be executed. In this case, there is a possibility that more than one condition might be satisfied and get executed.

Example - Switch

[Line : MFTBDetails] Fields : MFTBName

Right Fields : MFTBDrAmt, MFTBCrAmt

Switch : Case 1 : MFTBDtlsClsgG1000 : $ClosingBalance > 1000

Switch : Case 1 : MFTBDtlsClsgL1000 : $ClosingBalance < 1000

[!Line : MFTBDtlsClsgG1000]

Local : Field : MFTBDrAmt : Style : Normal Bold

Local : Field : MFTBCrAmt : Style : Normal Bold

[!Line : MFTBDtlsClsgL1000]

Local : Field : MFTBDrAmt : Style : Normal

Local : Field : MFTBCrAmt : Style : Normal

In this code snippet, the condition specified in the switch statements will be checked one after another. The first statement satisfying the given condition will be executed, and all other statements grouped within the label ‘Case 1’ will not be executed further, unlike ‘Option’. The behaviour similar to ‘Option’ can be achieved by specifying different labels, if required.

Learning Outcome

Access Specifiers and General symbols are the different special symbols used in TDL.

The Access Specifiers @ and @@ are used for accessing the values of Local and global formula, respectively.

# can be used for referencing a field or modifying the existing definition.

## is used for accessing the value from a Local or Global variable.

$ is used for accessing a method or UDF and $$ is used for calling a function.