0.9b (c) 1995 Peter Childs
>>--IF-expression-+-+THEN-+-+instruction-+--------------------+--->< +;+ +;+ +-ELSE-+-+instruction+ +;+
IF is used to conditionally process an instruction or group of instructions depending on the evaluation of the expression. The expression must evaluate to 0 or 1.
The instruction after the THEN is processed only if the result of the evaluation is 1. If you specify an ELSE clause, the instruction after ELSE is processed only if the result of the evaluation is 0.
Example:
if answer='YES' then say 'OK!' else say 'Why not?'
Remember that if the ELSE clause is on the same line as the last clause of the THEN part, you need a semicolon to terminate that clause.
Example:
if answer='YES' then say 'OK!'; else say 'Why not?'
The ELSE binds to the nearest IF at the same level. The NOP instruction can be used to eliminate errors and possible confusion when IF constructs are nested, as in the following example.
Example:
If answer = 'YES' Then If name = 'FRED' Then say 'OK, Fred.' Else nop Else say 'Why not?'
Notes:
1. The instruction can be any assignment, command, or keyword instruction, including any of the more complex constructs such as DO, SELECT, or the IF instruction itself. A null clause is not an instruction; so putting an extra semicolon after the THEN or ELSE is not equivalent to putting a dummy instruction (as it would be in C). The NOP instruction is provided for this purpose.
2. The symbol THEN cannot be used within expression, because the keyword THEN is treated differently, in that it need not start a clause. This allows the expression on the IF clause to be terminated by the THEN, without a semicolon being required. If this were not so, users of other computer languages would experience considerable difficulties.
Inf-HTML End Run - Successful