Appendix 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. 10.7.2 FUNCTION CheckDivByte : BYTE If you define functions in your project with the name CheckDivByte, you can use them to check the value of the divisor if you use the operator DIV [ } 313] , for example to avoid a division by 0. The name of the function is defined and may have only this identifier.
NOTE System load CheckBound function may cause increased system load. Please use CheckBounds only for test purposes. VAR_INPUT divisor : BYTE; END_VAR Example of CheckDivByte implementation: IF divisor = 0 THEN CheckDivByte := 1;(**) ELSE CheckDivByte := divisor; END_IF 10.7.3 FUNCTION CheckDivReal : REAL If you define functions in your project with the name CheckDivReal, you can use them to check the value of the divisor if you use the operator DIV [ } 313] , for example to avoid a division by 0. The name of the function is defined and may have only this identifier. NOTE System load CheckBound function may cause increased system load. Please use CheckBounds only for test purposes.
TwinCAT 2 PLC Control 335 Version: 1.0