Atari 400 Basic Reference Manual page 27

Vintage computer
Hide thumbs Also See for 400:
Table of Contents

Advertisement

The IF/THEN statement is a conditional branch statement. This type ofbranch
occurs only if certain conditions are met. These conditions may be either
arithmetical or logical. If the aexp following the IF statement is true (non-zero),
the program executes the THEN part of the statement. If, however, the aexp is
false (a logical 0), the rest ofthe statement is ignored and program control passes
to the next numbered line.
In the format, IF aexp THEN lineno, lineno must be a constant, not an expression
and specifies the line number to go to if the expression is true. If several
statements occur after the THEN, separated by colons, then they will be ex-
ecuted if and only if the expression is true. Several IF statements may be nested
on the same
line.
For example:
The statements
R=9:
GOTO 100 will be executed only if X=S and
Y=3.
The
statement Y
=
3 will be executed if X= 5.
The following program demonstrates the IF/THEN statement.
5
GRAPHIC~;
0 :?
:?
II
IF DH10
11
10 ?
=
? "ENTER Au
j :
HlPUT
A
20
IF
A= 1
THEH
4t1 : F.:Et-1 t·1i-'ttT I PLE
:::TATH1Et·H
~:; HEF.~E ~·JILL t£UEF.~
BE E:=<ECUTED!
!
30 ?
=
?
II
A
I~:;
HOT 1
.
E:=<ECUT
I oN com r
t·UE
s
HH~E L·JHH~
THE
D~PPE::s
I
Ot·i
r s
FALSE .
II
40 IF A=l THEt·i ? ;
'?
11
A=1
II:?
"\'ES.. IT' IS
REALL'l' 1.
II
:
REt-1 t1UL iiPLE
:~;TATEt1HHS
HEPE
WLL BE E>TCUTED ot·ll\' IF
A=l ! !
50
·?
:?
HE>~ECUTIOf·~
COt·iT I
~-iUE~;
HEF.:E IF A<
>
1 OF.: AFTEF:
I
'rE; ·'
IT I
~3
REALL'r' 1
I
Is D I SF'
LA'r'ED.
u
6f1
GOTO 10
Figure 4-7.
IF/
THEN Program
Et-HER
A
A IS t·WT 1 . E:;::ECUT IOH COt-H
H~UE~3 HEF.~E ~JH
Et·l THE
E:=O::PRESSIOt-~
IS
FAL~3E.
E>{ECUTIOt-~
COtH
H~UES
HERE IF A<> 1 OR AFTE
R ''lES) IT IS REALL\' 1' IS DISPLAYED
.
EtHER A
A=1
'/ES ) IT IS F.:EALL \' 1
.
E::<ECUTIOt-~
COtH H4UE::; HEF.:E IF A<> 1 OR AFTE
R
"'i'E~:;
.
. IT I::; F.:EALL'r' 1' IS DISPLA'/ED.
ENTEP A
Figure 4-8.
IF/
THEN Program Execution.
(entered Z)
(entered 1)
Program Statements
19

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

800

Table of Contents