Sharp PC-1500 Instruction Manual page 49

Hide thumbs Also See for PC-1500:
Table of Contents

Advertisement

All
and
more
about Sharp
PC-1
500 at
http://www.PC-1500.info
Normally,
of course,
this
program
would
~xccutc
in
ascending
line-number
sequence.
The
effect of the GOTO
in line
20.
however,
is
to
cause
SHARP to
proceed immediately
to
line
50
and
to
begin
in
ascending sequence
from
there,
lines
30 and 40
arc never
cxccu'ted.
The
general
form
of
the GOTO statement
is:
£QIQ
expression
\Yhere:
expression
cv.aluates
to
a number which
is
a valid
program
line-number
(i.e.
1
through
65279)
.
NOTE:
Specifying a
line·number
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
statements 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
statements
can be
inserted
in each
of the
sections which are
fo
rmed
by
the
GOTO statements.
As
an
example
of this
structure
in
practice, the following segment
from
a
checkbook
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
" TRANSACTION
AMOUNT?", TA
25 IF TA
=
0
THEN GOTO 80
30 B
=
B
+
A
40 IF TA< 0
THEN
GOTO
70
50
PR INT "DEPOSIT
OF $";TA;
"
POSTED"
60 GOTO 80
70
PRI
NT TA;
" DOLLARS WITHDRAWN"
80
PRINT
"FINAL
BALANCE
=
";
B
90
ENO
47
Do not
sale
this PDF
!!!

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents