Radio Shack TRS-80 PC-3 Owner's Manual page 139

Table of Contents

Advertisement

1 IF condition TH EN statement
2 IF condition statement
Abbreviations: none for IF,
T.,
TH., THE.
Purpose
The IF ... TH EN verb pai r is used to execute or not execute a statement, depending on conditions at the ti me the program is run.
Use
In the normal running of a BASIC program, statements are executed in the sequence in which they occur. The IF ... THEN
verb pair allows decisions to be made during execution so that a given statement is executed only when desired. When the
condition part of the IF statement is true, the statement is executed; when it is False, the statement is skipped.
The condition part of the IF statement can be any relational expression as described in Chapter 4. It is also possible to use a
numeric expression as a condition, although the intent of the statement will be less clear. Any expression which evaluates to
zero or a negative number is considered False; any which evaluates to a positive number is considered True.
The statement which follows the THEN may be any BASIC statement, including another IF... THEN. If it is a LET statement,
the LET verb itself must appear. Unless the statement is an EN D, GOTO, or ON ... GOTO, the statement following the IF ...
THEN statement is the next one executed, regardless of whether or not the condition is True.
The two forms of the IF statement are identical in action, but the first form is clearer.
139

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents