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

What’s New in Release 1.52

In this release, major enhancements have taken place at the Collection level and in the User Defined Functions. Further sections talk in depth about the usage of Data Source attribute in Collection and the various Looping Constructs inside a Function.

Few generic built-in functions - $$AccessObj, $$FirstObj and $$LastObj have been introduced. Https client capability has been enhanced in Tally to exchange data with other applications securely. Https sites can be used for ftp upload, posting request and receiving data in collection.

Collection Enhancements - Attribute ‘Data Source’ enhanced

The TDL programmers are aware that data from various data sources can be gathered in a collection. Till the release 1.5, the data sources were Tally database, XML, HTTP, ODBC and DLL. After the multi-line selection capability was introduced, a report or a function could be launched from the current report based on the specified scope. The different scopes that could be specified were Selected lines, Current line, Unselected lines, etc.

Now, the objects can also be gathered from the report or parent report using the Type parameter for the Collection attribute Data Source . This new capability allows the access of specific objects of a report from anywhere; like Functions, Subsequent report or the Current report itself. The Data Source attribute of the collection has been enhanced to support these two data sources, in addition to the existing data sources. The collection can be created directly from the specified data source and can be displayed in a report.

Syntax

Data Source : <Type> : <Identi t y> [:<Encoding>]

Where,

< T ype> specifi e s the type of da t a sou r ce, e. g ., File Xml, HTTP XML, Report, Parent Report.

<Identity> c an b e the file p ath o r the scope keyw o rds. If the type is File X ML o r HTTP X M L ,<identity> is the data source file path. If the type is Report or Parent Report then the scope keywords ‘Selected Lines’, ‘UnSelected Lines’, ‘Current Line’, ‘All Lines’, ‘Line’ and ‘Sorting Methods’ are used as identity.

<Encod i ng> can be ASCII o r UNICODE. It is Option a l. The default value is UNICODE . If the da t a source type is Report or Par e nt rep o rt, the enco d ing f ormat is ignored.

Existing Data Source Types

Example: XML file as data source

[Collection : My XML Coll]

Data Source : File XML : “C:\MyFile.xml”

In this code snippet, the type of file is ‘File XML’, as the data source is XML file. The encoding is Unicode by default, as it is not specified.

Example: HTTP as data source

[Collection : My XML Coll]

Data Source : HTTP XML : “http:\\localhost\MyFile.xml” : ASCII

In this code snippet, the type of file is ‘HTTP XML’, as the data source is obtained through HTTP. The encoding of the file ‘MyFile.XML’ is ASCII. While specifying the URL, now the https site can be given in Collection attributes Remote URL and Data Source.

Data Source Types Introduced

Example: Report as data source

[Collection : My Report Coll]

Data Source : Report : Selected Lines

The selected objects from the current report in which the collection is accessed, is the data source for the collection ‘MY Report Coll’.

Example: Parent Report as data source

[Collection : My Parent RepColl2]

Data Source : Parent Report : UnSelected Lines

The objects associated with all the unselected lines from the parent report are gathered for the collection ‘My Parent RepColl2’. The objects of the report with the given scope can be accessed from the report and functions which are called from the report.

Enhancements in User Defined Functions

In this release, ‘Dynamic action support’ has been provided for simple actions inside a function and the looping construct Walk Collection has been enhanced. New looping constructs FOR COLLECTION and FOR TOKEN have been introduced as well.

There are scenarios when the collection name is to be obtained from an expression while performing a Walk. WALK COLLECTION has been enhanced to provide this functionality. FOR COLLECTION loop has been introduced to walk the collection for a specific value. FOR TOKEN loop walks on the tokens within a string separated by a specified character.

Attribute ‘Walk Collection’ Enhanced

The Walk Collection attribute has been enhanced to accept Collection Name as an expression and an additional logical parameter. For example, now the collection name can be passed as parameter to the function while executing it.

Syntax

Walk Collection : <Expression> [:<Rev Flag>]

Where,

< Expression > can be any expression which evaluates to a collection name.

< Rev Flag > can be any expression which evaluates to a logical value. If it is True, then the collection objects are traversed in reverse order. This parameter is optional. The Default value is False.

Example

[Function : Test Function]

Parameter : parmcoll

|

|

05 : WALK COLLECTION : ##parmColl : Yes

The collection name is passed as parameter to the function ‘Test function’ and is walked in reverse order.

The code snippet to call the function ‘Test function’ from a key is as follows:

[Key : DC Call Function]

Key    : Enter

Action : CALL : Test Function : ##CollName

The collection name is passed through the variable ‘CollName’.

Dynamic Actions

Prior to Release 1.52, the dynamic action capability was available for global actions. It was possible to specify the Action Keyword and Action parameters as expressions. This allowed the programmer to execute actions based on dynamic evaluation of parameters. The ‘Action’ keyword can as well be evaluated dynamically.

The dynamic action capability is now introduced for simple actions inside a function. Expressions can be used to evaluate the name of the Action as well as Action parameters. The new action with Action keyword has been introduced to achieve this.

Syntax

Action : <Expression> : <Action Parameters>

Where,

< Expression > is any expression evaluating to a simple action name like LOG, DISPLAY, etc.

< Action Parameters > are parameters required by the action passed through an expression.

Example

[Function : ObjFunc]

|

|

02 : ACTION : LOG : "$" + ##pObjMethod

Inside a function, a global action can be called using dynamic action capability. In this case, the expression specified in the dynamic action is evaluated in the context of the function, and then the global action is executed.

The context of function elements like Variables, Objects, etc., can be used while calling a global action dynamically. For example, the variable name or methods of an object can be passed as parameter while executing the dynamic action.

Example

[Function : Dynamic Action Within Function]

Variable : DA Logical : Logical

|

|

40 : SET : DA Logical : Yes

50 : ACTION : Display : if ##DALogical then "Trial Balance" else "Balance Sheet"

In function ‘Dynamic Action Within Function’, first the expression is evaluated and then based on the value, the report ‘Trial Balance’ is displayed.

Looping Constructs ‘For Collection’ and ‘For Token’ introduced

Two new looping constructs - For Collection and For Token have been introduced in user defined functions.

Looping Construct - FOR COLLECTION

When WALK COLLECTION is used inside a function, the object of collection is set as the current object in the context of iteration, i.e., the loop is executed for each object in the collection, making it as the current context.

The newly introduced FOR COLLECTION provides a context free walk, as the current object is not set as the current object context while looping. It loops on the collection for the specific value and returns the value in the iterator variable. The value of the iterator variable can be referred to by the actions inside the For Collection loop.

Syntax

FOR COLLECTION : <IteratorVar> : <CollExprn> [:<Value Exprn : <Rev Flag>]

Where,

< Iterator Var > is the name of the variable which is used for the iteration. This variable is created implicitly.

< Coll Exprn > can be any expression which evaluates to a collection name.

< Value Exprn > can be any expression, whose value is returned in the iterator variable. If the value expression is not specified, the name of the object is returned.

< Rev Flag > can be any expression which evaluates to a logical value. If it is True, then the collection objects are traversed in reverse order. This parameter is optional. The Default value is False.

Example

[Function : Test Function]

|

|

30 : FOR COLLECTION : i : Group : $ClosingBalance > 1000

40 : LOG : ##i

50 : END FOR

The value Yes is logged in the file ‘TDLFunc.log’ if the closing balance is greater than 1000, else No .

Looping Construct - FOR TOKEN

The looping construct FOR TOKEN is used to walk a String expression separated by a delimiter character. It loops on a String expression and returns one value at a time. The value is returned in the iterator variable.

Syntax

FOR TOKEN : <IteratorVar> : <SrcStringExprn> [:<DelimiterChar>]

Where,

< IteratorVar Name > is the name of the variable used for iteration. The variable is created implicitly.

< Src String Exprn > can be any string expression separated by a <delimiter Char>.

< Delimiter Char > can be any expression which evaluates to a character used for separating the string expression. It is optional. The default separator char is ‘:’.

Example

[Function : Test Function]

|

|

01 : FOR TOKEN : TokenVar : "Tally : Shopper : Tally Developer" : ":"

02 : LOG : ##TokenVar

03 : END FOR

This code snippet will give the output as shown below:

Tally

Shopper

Tally Developer

Note: The same List is considered in explaining the further examples.

New Functions

New functions $$AccessObj , $$FirstObj and $$LastObj have been introduced in this release.

Function - $$AccessObj

The capability to access data objects associated with Interface objects was introduced in Tally.ERP 9. The attribute ‘Access Name’ is used to specify name to ‘Part’ or ‘Line’ Definition. This name can be used to refer to the Data Object associated with the Part or the Line.

A new function $$AccessObj has been introduced to evaluate the specified formula in the context of the Interface object identified by the given definition type and access name.

Syntax

$$AccessObj : <Definition Type> : <AccessNameFormula> : <Evaluation Formula>

Where,

< Definition Type > can be Part or Line.

< Access Name Formula > can be any formula which evaluates to a string.

< Evaluation Formula > is a formula which is evaluated in the context of the object identified by the definition type and the access name.

Example

[Line : AccessObj]

Fields : AccessObj AccessName : "AO1"

On : Focus : Yes : CALL : AccessObj

[Field : AccessObj]

Set As : $Name

[Function : AccessObj]

Variable : AccessObj : String

00 : SET : AccessObj : $$AccessObj:Line:"AO1":$Name

10 : LOG : ##AccessObj

The Line ‘AccessObj’ is identified by the access name ‘AO1’. The access name is used while evaluating the value of $Name.

Functions - $$FirstObj and $$LastObj

The objects of the collection are available in the context of repeat line or while performing a walk inside a function. The functions $$FirstObj and $$LastObj can be used to find the first or the last object of the collection respectively.

Function - $$FirstObj

The function $$FirstObj returns the value of the specified method for the first object of the collection.

Syntax

$$FirstObj : <MethodName>

Where,

< Method Name > is the name of a method of the current object in context.

Example

40 : LOG : "First Object : " + $$FirstObj:$Name

$$FirstObj logs the name of the first object of the collection, which is used in Walk Collection.

Function - $$LastObj

The function $$LastObj returns the value of the specified method for the last object of the collection.

Syntax

$$LastObj : <MethodName>

Where,

< Method Name > is the name of a method of the current object in context.

Example

50 : LOG : "Last Object: " + $$LastObj:$Name

The function $$LastObj logs the name of the last object of the collection, which is used in Walk Collection.

https URL support in Tally

Https client capability has been enhanced in Tally to exchange data with other applications securely. Https sites can be used for ftp upload, post request and receiving the data in collection. Now, data can be uploaded to https site, or request to the https site can be sent, using the action HTTP Post. The URL for the https site can be specified while gathering data in a collection.

Example: Upload

In the upload configuration screen, the URL for https site can be given as shown:

Figure_1._Upload_Configuration_Screen_(1.52).jpg

Example: Action HTTP Post

[Button : PostButton]

Key : Ctrl+K

Action : HTTP Post : @@MyURL : ASCII : HTTP Post ReqRep :HTTP Post Response Report1 : HTTP Post Response Report

[System : Formula]

MyURL : “https//www.testserver.co.in/CXMLResponse as per tally.php"

Example: In collection

[Collection : https Coll]

Remote URL : “https//www.testserver.co.in/TestXML.xml”