EasyManua.ls Logo

Commodore 128 - Page 282

Commodore 128
448 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
The ELSE clause, if present, must be on the same line as the
IF...THEN portion of the statement, and separated from the THEN
clause by a colon. When an ELSE clause is present, it is
executed only when the expression is false. The expression
being evaluated may be a variable or formula, in which case it is
considered true if nonzero, and false if zero, ln most cases, there
is an expression involving relational operators ( =, <, > , < = , >
= ,< > ) .
The IF...THEN statement can take two alternate forms:
IF expression THEN line number
or
IF expression GOTO line number
These forms transfer program execution to the specified line
number if the expression is true. Otherwise, the program resumes
with the program line number immediately following the line
containing the IF statement.
EXAMPLE:
50 IF X > 0 THEN PRINT OK: ELSE END
This line checks the value of X. If X is greater than 0, the
statement immediately following the keyword THEN (PRINT
OK ) is executed and the ELSE clause is ignored. If X is less
than or equal to 0, the ELSE clause is executed and the
statement immediately following THEN is ignored.
10 IF X=10 THEN 100
20 PRINTX does not equal 10
99 STOP
100 PRINT X equals 10
This example evaluates the value of X. IF X equals 10, the
program control is transferred to line 100 and the message X
EQUALS 10 is printed. IF X does not equal 10, the program
resumes with line 20, the C128 prints the prompt X does not
equal 10 and the program stops.
NOTE: The ELSE extension cannot be used in C64 mode.
17-40

Table of Contents

Other manuals for Commodore 128

Related product manuals