Conditional pragmas, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 1013

Advertising
background image

L-force | PLC Designer

Programming Reference

DMS 4.1 EN 03/2011 TD29

1011

Conditional Pragmas
The ExST (Extended ST) language supports several conditional pragma instructions
which affect the code generation in the pre-compile or compile process.
The implementation code which will be regarded for compilation for example might
depend on whether a certain data type or variable is declared, whether a type or
variable has got a certain attribute, whether a variable has a certain data type,
whether a certain POU or task is available resp. is part of the call tree, etc.

Note: It is not possible for a POU or GVL declared in the POUs tree to use a
"{define...}" declared in an application. Defines in applications will only have effect
on interfaces inserted below the respective application.

{define identifier
string
}

During preprocessing all subsequent instances of the identifier will be replaced
with the given sequence of tokens, if the token string is not empty (which is
allowed and well-defined). The identifier remains defined and in scope until the
end of the object or until it is undefined in an {undefine} directive. Used e.g. for
"conditional compilation", see below.

{undefine identifier} .

The identifier's preprocessor definition (by {define}, see above) will be removed,
the identifier hence is "undefined". If the specified identifier is not currently
defined, this pragma will be ignored.

{IF expr}
...
{ELSIF expr}
...
{ELSE}
...
{END_IF}

These are pragmas for conditional compilation. The specified expressions exprs
are required to be constant at compile time; they are evaluated in the order in
which they appear until one of the expressions evaluates to a nonzero value. The
text associated with the successful directive is preprocessed and compiled
normally; the others are ignored. The order of the sections is determinate;
however, the elsif and else sections are optional, and elsif sections may appear
arbitrarily often.
Within the constant expr several "conditional compilation operators" can be
used, which are described below.

Advertising