Subrange type
A subrange type is a data type whose value range is a subset of a base type.
Syntax in the declaration:
<variabel name> : <integer type> ( <lower index limit> .. <upper index limit> )
| Valid IEC identifier For more information, see: Rules and recommendations for Identifier Designation |
| Integer basic data type for the subrange
|
| Constant for the lower limit of the area which has to be compatible with the basic data type The lower limit itself is included in this range. |
| Constant for the upper limit of the area which has to be compatible with the basic data type The upper limit is also included in this range. |
VAR i : INT (-4095..4095); ui : UINT (0..10000); END_VAR
If you assign a value to a subrange type in the declaration or implementation part that is not within this range, then CODESYS issues an error message.
i:=5000 //Results in an error message
Tip
Note: In runtime mode, it is possible to monitor the range limits of a subrange type by using the implicit monitoring functions CheckRangeSigned
and CheckRangeUnsigned
.