User-Defined Expression Tokens

MapPrep

User-Defined Expression Tokens

 

CodeGen supports user-defined expression tokens in all loops via the <IF USERTOKEN_tokenname> and <IF NOT_USERTOKEN_tokenname> tags. User defined expression tokens allow you to conditionally process template code based on the presence or absence of a particular user defined token.

Multi-Line User Defined Token Expressions

Multi-line user token expressions occur when the opening and closing conditional tags appear on separate lines in a template file, and delimit one or more entire lines of template code, like this:

<****_LOOP>

[code]

<IF expression>conditional code
[<ELSE>
conditional code]
</IF[ expression]>

[code]

</****_LOOP>

Multi-line user token expressions cause one or more lines of output code to be included or excluded, based on the evaluation of the expression.

In-Line User Defined Token Expressions

In-line user token expressions occur when the opening and closing conditional tags appear on the same line in a template file, and delimit part of a line of template code, like this:

<****_LOOP>

[code]
[code] <IF expression> conditional code </IF[ expression]> [code]
[code]

</****_LOOP>

In-line user token expressions cause part of an output line to be included or excluded based on the evaluation of the expression.

Note: Multi-line expressions may be nested within one another, and in-line expressions may be nested within multi-line expressions. However, in-line expressions may not be nested inside one another.

Example

If generating code with a command similar to:

codegen -s CUSTOMER -t FileIo -ut MYTOKEN=value

 

The template file code could include code based on the presence of the MYTOKEN user defined token like this:

<IF USERTOKEN_MYTOKEN>
This code will be included if the user token is specified
</IF>

Or

<IF NOT_USERTOKEN_MYTOKEN>
This code will be included if the user token is specified
</IF>

 

 

 


Copyright © 2018  Synergex International, Inc.