next up previous contents
Next: RETURN Up: THE SCL COMMANDS. Previous: DO/ENDDO   Contents


IF / ELSEIF / ELSE / ENDIF

The IF command has one prompt:

Expression? (string)
Logical expression evaluation has now been implemented. Thus the string can be any of: (a), a logical variable name (including the readonly variables .TRUE., TRUE, T, .FALSE., FALSE or F); (b), a relational expression; (c), a logical expression consisting of one or more relational expressions separated by logical operators. Relational expressions are defined to be simple binary expressions - i.e. one operand and two operators, and may compare either two string items or two numeric items. String items may be tested only for equality or inequality and are case-independent.

Valid Relational operators
= (equal)
>< & <> (not equal)
< (less than)
> (greater than)
<= & =< (less than or equal to)
>= & => (greater than or equal to)

Only the simplest logical operators are provided. Note that for now the logical NOT (~) and arithmetic unary minus (-) are the same thing, but I do not guarantee that this will continue, and in any case, expressions are easier to use if you distinguish between the two uses. The two binary operators (& and !) have the same precedence, but lower than that of any of the relational operators. Expressions are evaluated left to right.

Valid Logical operators
& AND
! OR
~ NOT

The expression may optionally be enclosed in brackets for readability.

If the expression encountered by an IF or ELSEIF statement is logically true then the following commands to the next ELSEIF/ELSE or ENDIF will be executed and any further commands before the ENDIF ignored; otherwise they will be skipped until the next ELSEIF which is treated like a new IF. If an ELSE statement is encountered without any of the tests on the IF or any following ELSEIFs having been true the commands following the ELSE are executed. IF structures can be nested to a depth of 16.

Example:

             !  Command file to demonstrate IF command
                   if 3*x^2+4 <= 27
                     offset x
                   elseif (x/4 = 2)
                     x = 27
                   else
                     print 'nothing done'
                   endif


next up previous contents
Next: RETURN Up: THE SCL COMMANDS. Previous: DO/ENDDO   Contents
Jamie Leech 2004-08-16