Reference programming Requirements 7.4 System Functions 7.4.1 CheckBounds If you define a function in your project with the name CheckBounds you can use it to check for range overflows in your project! The name of the function is defined and may have only this identifier. An example of how this function is implemented is shown below: The function can cause a significant increase in system load, so it should only be used for testing purposes. FUNCTION CheckBounds : DINT VAR_INPUT index, lower, upper : DINT; END_VAR Example of CheckBounds function implementation:
IF index CheckBounds := lower; ELSIF index>upper THEN CheckBounds := upper; ELSE CheckBounds := index; END_IF The following typical program for testing the CheckBounds function goes beyond the boundaries of a defined array. The CheckBounds functions makes sure that the value TRUE is not assigned to the position A[10], but rather to the upper area boundary A[7] which is still valid. Therefore, the CheckBounds function can be used to correct extensions beyond array boundaries. TX1200 218 Version: 1.3 Development environment Target system type PLC libraries to include TwinCAT v2.7.0 PC (i386) PLCSystem.Lib TwinCAT v2.8.0 PC (i386) TcSystem.Lib