Judgement Command (If - Then) - Radio Shack TRS-80 PC-4 Owner's Manual

Trs-80 pc-4
Hide thumbs Also See for TRS-80 PC-4:
Table of Contents

Advertisement

jump to the line number which is the result of A* 100
(jump to line 200 if A is 2)
jump to the P2 program area
GOTO
#2
GOTO
#X
jump to the program area which is the value of variable X
(jump to the P8 program area if X is 8)
GOTO
#P+ 1 .. ,......
jump to the program area which is the result of
P+l
(jump
to the P5 program area if P is 4)
GOTO A*
100
.
A GOTO statement is used to repeat program execution from the beginning or to jump
to another program to perform a particular calculation.
5-6-4 Judgement Command
IF statement
An IF statement is also called a "conditional jump". This command is used to perform
some operation or to jump to a designated location only when a certain condition is
satisfied.
Format: IF comparison expression {THEN line number or
~
(.n=0 through 9)}
; command or substitution statement
The comparison expression following the "I
F"
compares the right side and the left
side of
"="
(equal to) or
"#"
(not equal to) signs, and
if
the condition is satisfied,
program execution proceeds to the specified location. If the condition is not satisfied,
execution proceeds to the next line.
This operation is shown in the flowchart below.
IF
NO
As the flowchart shows, if the IF statement condition
i s
fulfilled, the process goes in
the "YES" direction, but if the IF statement is not fulfilled, the process continues
in the "NO" direction.
In other words, an IF statement ind icates a branch and selects the next operation as a
direct result of judgement. An I F statement can be used to terminate a loop (repetition)
when the number of data is unknown or to select the next operation based on a calcula-
tion result, etc.
Constants/variables/numerical expressions/character constants/character variables can be
used for this comparison.
-48-

Advertisement

Table of Contents
loading

Table of Contents