Previous Topic Next topic Print topic


Optimizing IF Statements

The IF statement is designed to evaluate its result in a temporary field of the largest possible significance to hold the result. This temporary field might be of a larger significance than is actually required, causing the operation to be slower than it could be. The temporary field is stored in the target field with any necessary truncation. For example:

IF a + b < c

It is often better to define a temporary data item of the required size and use that to hold the result of the arithmetic, as follows:

MOVE a TO temp
ADD b TO temp
IF temp < c
Previous Topic Next topic Print topic