Conditional Processing

MapPrep

Conditional Processing

 

Conditional processing blocks provide the ability to include or exclude parts of a template file based on the presence or absence of identifiers that can be defined using the -define command line option. Unlike expression tokens the evaluation of conditional processing expressions a does not change based on the current context within a template file, rather it remains consistent throughout the entire code generation job.

 

Conditional processing is based on identifiers that can be defined on the command line. For example:

 

codegen -s CUSTOMER -t FILEIO_CLASS -define ATTACH_IO_HOOKS -r

 

And is used to include or exclude parts of the code in a template file by evaluating the presence or absence of the identifier via special <IF DEFINED_identifier> and <IF NOT_DEFINED_identifier> tokens. For example:

 

(IO_OPEN_UPD),

begin

          open(a_channel=0,u:i,"<FILE_NAME>") [ERR=openError]

          <IF DEFINED_ATTACH_IO_HOOKS>

          new <StructureName>Hooks(a_channel)

          </IF>

end

 

There are two types of conditional processing block:

 

Multi-line conditional processing blocks cause one or more lines of code to be included or excluded based on the presence or absence of the defined identifier and occur when the opening and closing conditional tags appear on separate lines in a template file. They delimit one or more entire lines of template code, like this:

<IF [NOT_]DEFINED_identifier>code
</IF>

In-line conditional processing blocks cause part of a line to be included or excluded and occur when the opening and closing conditional tags appear on the same line in a template file. They delimit part of a line of template code, like this:

[code] <IF [NOT_]DEFINED_identifier> code </IF> [code]

Conditional Processing Block Else Clauses

Else clauses are supported in multi-line conditional processing blocks, like this:

<IF [NOT_]DEFINED_identifier>
code
<ELSE>
code
</IF>

And in in-line conditional processing blocks, like this:

[code] <IF [NOT_]DEFINED_identifier> code <ELSE> code </IF> [code]

Nesting Conditional Processing Blocks

Multi-line conditional processing blocks may be nested within one another. For example:

<IF DEFINED_identifier1>
[code]
<IF DEFINED_identifier2>
code
</IF>
[code]
</IF>

In-line conditional processing blocks may be nested within multi-line conditional processing blocks.

<IF DEFINED_identifier1>
[code]
[code] <IF DEFINED_identifier2> code </IF> [code]
[code]
</IF>

Multiple in-line conditional processing blocks may be used within the same line:

[code] <IF DEFINED_identifier1> code </IF> [code] <IF DEFINED_identifier2> code </IF> [code]

In-line conditional processing blocks may be nested within one another:

[code] <IF DEFINED_identifier1> [code] <IF DEFINED_identifier2> code </IF></IF> [code]

 

 

 


Copyright © 2018  Synergex International, Inc.