Conditional Expression

Comparisons and Print command operands use self-typed expressions. Their type is determined by the types of variables they reference or the result type of functions the call. Self-typed expressions with mixed type operands are not allowed unless type casting functions are used.

   IF Variable = 0              :The comparison type is the type of Variable.
   IF Byte = Parcel             :The type is ambiguous and is not allowed.
   IF parcel{ Byte } = Parcel   :The type cast resolves the ambiguity.
   IF 6 = 9                     :Constants are untyped; this is not allowed.

A comparison can be coded in three different forms. You can compares two expressions with a comparison operator. For integer expressions the inequality operators are signed. They can also be compared using the unsigned comparison operators.

   =    ~=        Equal / Not equal
   <    >         Less than / Greater than
   <=   =<        Less than or equal
   >=   =>        Greater than or equal

   _<   _>        Unsigned less than / Greater than
   _<=  _=<       Unsigned less than or equal
   _>=  _=>       Unsigned greater than or equal

In many cases can omit the second expression and the comparator. When the expression is set the condition is met.

   IF Index                :True when the numeric Index is non-zero.
   IF Prefix ! Text        :True when the string append result is not empty.
   IF @Pointer             :True when the pointer is not null.

With a Comparison List you can compare an expression to a list of constants or a range of values. In this example C has type Byte and is compared to see if it is a plus or minus sign or a decimal digit.

   IF C = '+' | '-' | '0' to '9'

You can use either a "=" or "~=" comparator in a comparison list. The expression on the left side can be either an integer or enumerated type. Use the "to" keyword to specify a range of values. The comparison for the range is unsigned unless the constant for the start of the range is negative.

   IF N = -9 to 9                      :This range uses signed comparisons.

You can include multiple comparisons in a compound condition with the "and" and "or" keywords. Each comparison is evaluated left to right and will terminate early when a comparison resolves the compound condition. After termination any subsequent conditions will not be evaluated.

In this example if the Pointer is null then the condition as a whole is false and the second comparison will not be performed. This avoids dereferencing the null pointer in the second comparison.

   IF @Pointer  and  Pointer`Value < 0

"And" compound operations take precedence over "or". Parenthesis are not permitted, but the condition "A or B and C or D" would be interpreted as:

   A or (B and C) or D

Arithmetic Expression

Intrinsic Function