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

Page 1014

Advertising
background image

L-force | PLC Designer

Programming Reference

1012

DMS 4.1 EN 03/2011 TD29

Conditional compilation operators
Within the constant expression expr of a conditional compilation pragma ({if} or
{elsif}), see above, several operators can be used. These operators itself may not be
undefined or redefined via {undefine} or {define}, respectively. Regard that these
expressions as well as the definition done by {define} can also be used in the 'Compiler
defines' in the Properties dialog of an object (category 'Build').

defined (identifier)

When applied to an identifier, its value is TRUE if that
identifier has been defined with a {define} instruction and
not later undefined using {undefine}; otherwise its value is
FALSE.
Example:
Precondition: There are two applications App1 and App2.
Variable "pdef1" is defined by a {define} instruction in App1,
but not in App2.
{IF defined (pdef1)}
(*this code is processed in application "App1"*)
{info 'pdef1 defined'}
ivar := ivar + SINT#1;
{ELSE}
(*this code is processed in application "App2"*)
{info 'pdef1 not defined'}
ivar := ivar - SINT#1;
Here additionally an example of a message pragma is
included: Only information string "pdef1 defined" will be
displayed in the message window when the application is
built, because pdef1 actually is defined. Info message "pdef1
not defined" will be displayed in case pdef1 is not defined.

defined (variable:variable)

When applied to a variable, its value is TRUE if this particular
variable is declared within the current scope; otherwise
FALSE.
Example:
Precondition: There are two applications App1 and App2.
Variable "hallo" is declared in App2, but not in App1.

{IF defined (variable:g_bTest)}
(*the following code is only processed in application "App2"*)
g_bTest := x > 300;
{END_IF}

Advertising