L-force | plc designer – Lenze PLC Designer PLC Designer (R2-x) User Manual
Page 532

L-force | PLC Designer
Data types in PLC Designer
530
DMS 3.2 EN 02/2011 TD29
The same applies to the function CheckRangeUnsigned: function name and interface
must be correct.
FUNCTION CheckRangeUnsigned : UDINT
VAR_INPUT
value, lower, upper: UDINT;
END_VAR
Stop!
If neither of the functions CheckRangeSigned or CheckRangeUnsigned is present, no
type checking of subrange types occurs during runtime! The variable i could then
take on any value between –32768 and 32767 at any time!
If neither of the functions CheckRangeSigned or CheckRangeUnsigned is present
like described above, there can result an endless loop if a subrange type is used in a
FOR loop. This will happen when the range given for the FOR loop is as big or bigger
than the range of the subrange type !
The CheckRangeSigned-function provided with the Check.Lib library is just a sample
solution! Before using the library module check whether the function is working as
requested for your project, or implement an appropriate CheckRange-function
directly as a POU in the project.
Example:
VAR
ui : UINT (0..10000);
END_VAR
FOR ui:=0 TO 10000 DO
...
END_FOR
The FOR loop will never be finished, because ui cannot get bigger than 10000.
Also take care of the definition of the CheckRange functions when you define the
incremental value of a FOR loop !