beautypg.com

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

Page 1032

background image

L-force | PLC Designer

Programming Reference

1030

DMS 4.1 EN 03/2011 TD29

This check function has to treat boundary violations by an appropriate method (for
example by setting a detected error flag or changing the index). The function will be
called implicitly as soon as a variable of type array is assigned.

Attention: In order to maintain the check functionality do not change the
declaration part of an implicit check function.

Example for the use of function CheckBounds:
The default implementation of the check function is the following
Declaration part:

// Implicitly generated code : DO NOT EDIT
FUNCTION CheckBounds : DINT
VAR_INPUT
index, lower, upper: DINT;
END_VAR

Implementation part:

// Implicitly generated code : Only an Implementation suggestion
IF index < lower THEN
CheckBounds := lower;
ELSIF index > upper THEN
CheckBounds := upper;
ELSE
CheckBounds := index;
END_IF


When called the function gets the following input parameters:
• index: field element index
• lower: the lower limit of the field range
• upper: the upper limit of the field range
As long as the index is within the range, the return value is the index itself. Otherwise -
in correspondence to the range violation- either the upper or the lower limit of the
filed range will be returned.