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

Page 1039

Advertising
background image

L-force | PLC Designer

Programming Reference

DMS 4.1 EN 03/2011 TD29

1037

Example of an endless loop:

VAR
ui : UINT (0..10000);
END_VAR

FOR ui:=0 TO 10000 DO
...
END_FOR

The FOR loop will never be left as the check function prevents the variable ui to be
assigned to values greater than 10000.

References
This data type is an extension to the IEC 61131-3 standard.
A REFERENCE is an alias for an object. The alias can be written or read via identifiers.
The difference to a pointer is that the value pointed to is directly affected and that the
assignment of reference and value is fix. The address of the reference must be set via a
separate assignement operation. Whether a reference points to a valid value (that is
unequal 0) can be checked with the help of a special operator, see below.
A reference is declared according to the following syntax:
Syntax
<identifier> : REFERENCE TO <data type>
Example declaration:

ref_int : REFERENCE TO INT;
a : INT;
b : INT;

ref_int is now available for being used as an alias for variables of type INT.

Advertising