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.

   =    ~=        Equal / Not equal
   <    >         Less than / Greater than
   <=   =<        Less than or equal
   >=   =>        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.

For integers the inequality operators are signed. Unsigned comparisons are performed with the "lt" or "le" functions for Less-than or Less-than- or-equal respectively. At first this may seem awkward, but consider that comparison functions are rarely needed. In many contexts a signed comparator will suffice when values are small enough that the upper bit is zero. Also the following comparison list construct can check unsigned ranges.

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.

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

Assignment Command