The ELSE Instruction

ELSE identifies the instruction to be run if the expression is false. To tell the interpreter to select from one of two possible instructions, use:

IF expression
 THEN instruction1
ELSE instruction2

You could include the IF-THEN-ELSE format in a procedure like this:

IF answer = 'YES'
 THEN SAY 'OK!'
ELSE SAY 'why not?'
Try the next example, GOING.CMD, to see how choosing between two instructions works.
/* Using IF-THEN-ELSE */
SAY "Are you going to the meeting?"
PULL answer
IF answer = "YES"
 THEN
 SAY "I'll look for you."
ELSE
 SAY "I'll take notes for you."
EXIT

When this procedure is run, this is what you will see on your screen:

[C:\]GOING
Are you going to the meeting?

yes

I'll look for you.

[C:\]


[Back: Making Decisions(IF THEN)]
[Next: SELECT, END, WHEN, OTHERWISE, and NOP Instructions]