Variables, Addressing bits in variables, Variables 7 – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 1099: L-force | plc designer

Advertising
background image

L-force | PLC Designer

Programming Reference

DMS 4.1 EN 03/2011 TD29

1097

16.4.2

Variables
Variables can be declared either locally in the declaration part of a POU or in a Global
Variable List.
See Variables Declaration for information on the declaration of a variable, including
the rules concerning the variable identifier and multiple use.
Variables can be used anywhere the declared type allows for them.
You can access available variables through the Input Assistant.

Accessing variables for arrays, structures and POUs
Use the following syntax for accessing...
Two-dimensional array components:
<Fieldname>[Index1, Index2]
Structure variables:
<Structurename>.<Variablenname>
Function block and program variables:
<Functionblockname>.<Variablename>

Addressing bits in variables
In integer variables individual bits can be accessed. For this purpose the index of the bit
to be addressed is appended to the variable, separated by a dot. The bit-index can be
given by any constant. Indexing is 0-based.

Note: Bit accesses used in visualizations will only work over a Data Server
connection if the bit index is defined literally (and not by a defined constant).

Syntax:
<variablename>.<bit index>

Example:

a : INT;
b : BOOL;
...
a.2 := b;

The third bit of the variable a will be set to the value of the variable b.

If the index is greater than the bit width of the variable, the following error message
will be issued: "Index '<n>' outside the valid range for variable '<var>'!"
Bit addressing is possible with the following variable types: SINT, INT, DINT, USINT,
UINT, UDINT, BYTE, WORD, DWORD.

Advertising