Preprocessor Directive

Preprocessor directives are part of TDL code, specified at the TDL definition level. It provides hints to Tally.Developer 9 Analyser to perform the respective functions.

Syntax - General Preprocessor Directive

[Desc Type: Desc Name]

<Preprocessor Directive Name : Value>

<Preprocessor Directive Name : Value>

.

.

Where,

Desc Type is the definition type like Report, Form, Part, and so on.

Desc Name is the name of the definition.

Preprocessor Directive Name is the name of the preprocessor directive.

Value can be a keyword, an identifier or a logical value based on the preprocessor directive.

Preprocessor Directive: InUse

The preprocessor directive InUse provides hints to Tally.Developer 9 Analyser for identifying dynamically used definitions in TDL. You can give preprocessor directive InUse for all definition levels. If you specify preprocessor directive at system definition level, the directive is applied to the next system definition specified under it.

Syntax - Preprocessor Directive InUse

[Source Desc Type : Source Desc Name]

<InUse:<Desc Type1> : <Desc Name>, <Desc Type2> : <Desc Name>, …>

<InUse: <Desc Type1> : <Desc Name>, <Desc Type2> : <Desc Name>, ...>

Where,

Source Desc Type is the type of source definition.

Source Desc Name is the name of source definition.

<Desc Type> is the type of definition dynamically used in the source definition.

<Desc Name> is the name of the definition dynamically used in the source definition.

Note: Ensure that every InUse statement is added as a separate line.

When a TDL project is compiled in Tally.Developer 9 releases earlier to Release 6, with Analyse option set in its properties, the analyser validates the entire code and identifies errors, warnings, and remarks and identifies the errors only from the statically used definitions. If definitions are used dynamically at runtime, the analyzer cannot determine the use of such definitions. In Release 6, with the help of the preprocessor directive InUse , you can identify the definitions which are used dynamically in the TDL code.

Example 1

Consider the following code snippet that is part of a program to display a report. The report GrossSalaryProjectionReport has a reference to a variable that is not defined.

In releases earlier to Release 6:

[Function: FunctionGrossSalaryProjection]

002: Action: Display: GrossSalaryProjectionReport

[Report: GrossSalaryProjectionReport]

Form : GrossSalaryProjectionForm

Variable: SalaryPeriodVariable

[Form: GrossSalaryProjectionForm]

Part: GrossSalaryProjectionPart

In the above example, the analyser can identify the report GrossSalaryProjectionReport as a used definition, and a variable SalaryPeriodVariable is specified in the report. But this variable is not defined in the code. Hence, when the project is compiled with the Analyse option set in its properties, it throws an error as given below:

Example 2

Consider the following code snippet that is part of a program to display a report that calculates the gross pay for all employees.

In releases earlier to Release 6:

[Function: FunctionGrossSalaryProjection]

002: Action: Display: GrossSalaryProjectionReport

[Report: GrossSalaryProjectionReport]

Variable: SalaryPeriodVariable

Repeat  : SalaryPeriodVariable

Set     : DSPRepeatCollection: "CollGrossSalaryProjectionPeriod"

[Variable: SalaryPeriodVariable]

Type    : String

Repeat  : ##DSPRepeatCollection

[Collection: CollGrossSalaryProjectionPeriod]

Type     : Period

Compute  : FullMonthFromName   : @@SFGrossSalProjMonthStart

Compute  : FullMonthToName     : @@SFGrossSalProjMonthEnd

ColumnVar: GrossSalPeriodVar

[System: Formula]

SFGrossSalProjMonthStart : $$MonthStart:##GrossSalPeriodVar

When this project is compiled using Tally.Developer 9 releases earlier to Release 6, the analyser cannot identify that the collection CollGrossSalaryProjectionPeriod is used in the code as it is set as a string value. So it will not throw any error.

In release Release 6 or later:

With the use of the preprocessor directive InUse the analyser identifies the presence of the collection and it throws s an error.

[Function: FunctionGrossSalaryProjection]

002: Action: Display: GrossSalaryProjectionReport

[Report: GrossSalaryProjectionReport]

<InUse:Collection:CollGrossSalaryProjectionPeriod>

Variable: SalaryPeriodVariable

Repeat  : SalaryPeriodVariable

Set     : DSPRepeatCollection: "CollGrossSalaryProjectionPeriod"

[Variable: SalaryPeriodVariable]

Type    : String

Repeat  : ##DSPRepeatCollection

[Collection: CollGrossSalaryProjectionPeriod]

Type     : Period

Compute  : FullMonthFromName   : @@SFGrossSalProjMonthStart

Compute  : FullMonthToName     : @@SFGrossSalProjMonthEnd

ColumnVar: GrossSalPeriodVar

[System: Formula]

SFGrossSalProjMonthStart: $$MonthStart:##GrossSalPeriodVar

In this example, since InUse is specified at the report level, the analyser identifies that the collection CollGrossSalaryProjectionPeriod is used in the code. Therefore, when the project is compiled, it throws an error as given below:

InUse with Modified Definitions

Preprocessor directive InUse can also be specified for modified definitions as given below:

Example

[#Key : Export Report]

<InUse: Report: TNAnnexureI, TNAnnexureII>

<InUse :RuleSet: TNAnnexureI>

Action: Export : ##SVeVATExportTitle

In this example, when the project is compiled, the anlayser validates the dynamically used definitions,  reports - TNAnnexureI and TNAnnexureII and RuleSet - TNAnnexureI.