User`s manual
4-17
ELSE
statement or line number
Used after IF to specify an alternative action in case the IF test fails. (When
no ELSE statement is used, control falls through to the next program line
after a test fails.)
Examples:
100
INPUT A$: IF A$="YES" THEN 300 ELSE END
In line 100, if A$ equals "YES" then the program branches to line 300. But if
A$ does not equal "YES", program skips over to the ELSE statement which
then instructs the Computer to end execution.
200
IF A<B PRINT"A<B"ELSE PRINT"B<=A"
If A is less than B, the Computer prints that fact, and then proceeds down to
the next program line,
skipping
the ELSE statement. If A is not less than B,
Computer jumps directly to the ELSE statement and prints the specified
message.
Then
control passes to the next statement in the program.
200 IF A>.001 THEN B=1/A: A=A/5: ELSE 260
If A >001 is True, then the next two statements will be executed, assigning
new values to B and A. Then the program will drop down to the next line,
skipping the ELSE statement. But if A >.001 is
False, the program jumps directly over to the ELSE statement, which then
instructs it to branch to line 260. Note that GOTO is not required after
ELSE.
IF-THEN-ELSE statements may be nested, but you have to take care to
match up the IFs and ELSEs.
10
INPUT "ENTER TWO NUMBERS";A,B
20
IF A<=B THEN IF A<B PRINT A;:ELSE PRINT "NEITHER";:ELSE PRINT
B;
30
PRINT"IS SMALLER"
RUN the program, inputting various pairs of numbers. The program picks
out and prints the smaller of any two numbers you enter.
Note that the THEN statements and the colons may be omitted from
line 20.