A
ll
and more about Sharp
PC
-1
500
at
http://www.PC-1500.info
Normally,
of
course, this program would
~xccutc
in
ascendi
ng
line-number
sequence.
The
effect
of
the GOTO in line
20.
however,
is
to
ca
us
e SHARP
to
proceed imm
ed
iately to line
50
and
to
b
eg
in in ascending sequence from there,
lines
30 and
40
arc never cxccu'ted.
The
g
enera
l
form
of the GOTO
statement
is:
£QIQ
expression
\Yhere:
expre
ssi
on
cv
.aluates to a
number
which
is a valid program line-number (i.e. 1 through
65279
).
NOTE: Specifying a line·numb
er
which
does
not exist will result
in
an ERROR
11
.
If
we wish
to
have several instructions executed
as
a result
of
a certain choice
we
use GOTO
st
atements in conjunction with the IF:
10
!E.
test TH
EN
GOTO 100
20
l statements here arc }
l performed only if the }
\ test
is
False. I
90
GOTO
200
100 l statements here are
l performed
only
if the
l test
is
True.
200
{ statements here
arc
{ always performed.
999
ENO
The
logic
of
this program is applicable
to
many
situations.
Any
number
of
statemen
ts
can be
inserted in each
of
the
sections which are formed
by
the
GOTO statements.
As
an example of this structure in practice,
the
following segment from a
ch
eckbook program
determines
whether
a given input amount
is
a
deposit
{positive number)or a withdrawal(negative
number). An initial balance is entered
by
the
user:
Program Listing:
10 INPUT "INITIAL BALANCE?", B
20
INPUT "
TRA
NSACTION AMOUNT?",
TA
25
IF
TA
= 0 THEN GOTO
80
30
B = B + A
40
IF
TA<
0 THEN GOTO
70
50
PR
I
NT
"DEPOS
IT OF
$";TA;
" POSTED"
60
GOTO
80
70
PRI
NT
TA; " DOLLARS WITHDRAWN"
80
PRINT
"FI
N
AL
BALANCE =
";
B
90
ENO
47
Do
not sale this PDF
!!!