$if

Conditional Processing

$if x op y

This "if" command is used to condition the processing of file commands on a comparison operation. If the condition is true, the following commands up to the next matching $else, $elseif or $endif are processed, and commands from the $else to the next matching $endif are ignored. Conditional commands may be nested to a depth of thirty-two levels. All condition sets must be properly terminated with balanced $endif statements.

The parameters on this command are used as follows:

x | the first operand, either a literal or @varname. |

op | the comparison operation to be performed: |

= | equal to |

!= | not equal to |

>= | greater than or equal to |

<= | less than or equal to |

> | greater than |

< | less than |

& | true if binary 'and' of two integers is non-zero |

$in | true if substring of |

$eq, | $ne, $ge, $le, $gt, $lt (see below) |

y | the second operand, either a literal or @varname. |

For the first seven items in the list above, if both the operands consist only of integers between -263+1 and 263-1, numeric comparisons are performed; otherwise text comparisons are performed.

All text and substring comparisons take account of the case of any alphabetic characters in the values. Double-quotes have no special significance and should therefore not be used to surround parameters.

Note that the command must conform to the simple syntax described above and complex expressions and parentheses are not supported. Only the first of the above operations found on the command will be acted on.

If you use numeric values with decimal points, note that 9.9 is bigger than 10.1 when a text comparison is performed. To avoid this problem, use the $eq and similar operation commands which force a correct numeric comparison. The result of comparison of non-valid numeric values with these operations is undefined. Because floating-point decimal values can never be held precisely in the binary format used inside most computer systems, numbers are considered equal if they differ by less than 0.00001.

Example:

$if @code = 1

$next_box good ; transfer to good.iif

$else

$next box bad ; transfer to bad.iif

$endif