Reference programming 7.4.2 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 [ } 198] , for example to avoid a division by 0. The name of the function is defined and may have only this identifier. The function can cause a significant increase in system load, so it should only be used for testing purposes. VAR_INPUT divisor : BYTE; END_VAR Example of CheckDivByte implementation: IF divisor = 0 THEN CheckDivByte := 1;(**) ELSE CheckDivByte := divisor; END_IF 7.4.3 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 [ } 198] , for example to avoid a division by 0. The name of the function is defined and may have only this identifier. The function can cause a significant increase in system load, so it should only be used for testing purposes. VAR_INPUT divisor : REAL; END_VAR Example of CheckDivReal implementation: IF divisor = 0 THEN CheckDivReal := 1; ELSE CheckDivReal := divisor; END_IF Operator DIV uses the output of function CheckDivReal as divisor.
In a program like shown in the following example this avoids a division by 0, the divisor (d) is set from 0 to 1. So the result of the division is 799. TX1200 219 Version: 1.3