Sharp PC-1500A Instruction Manual page 49

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

Advertisement

All
and
more
about Sharp
PC-1500
at
http://www.PC-1500.info
Normally. of course,
this
program
would
execute
in
asce·nding
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 sequf.?nce from
there.
Lines
30 and 40 are
never
executed.
The
general
form
of
the
GOTO
statement
is:
GOTO
expression
where:
expression
evaluates
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
\Vish to have
several
instructions executed
as
a
result
of
a
certain
choice
\VC
use
GOTO
statements in
conjunction
\Vith
the
IF
:
10
!E.
test
THEN GOTO
100
20
{
statements here are
{
performed only if
the
j
test is False.
90 GOTO 200
100
l
statements
here are
j
performed only
if
the
{
test
is
True.
200
{
statements here
are
{
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
arc formed
by
the
GOTO
statements.
As an example of
this structure
in
practice.
the
following
segment
rrom a checkbook
program
determines whether a given
input
amount is a deposit (positive number) or a
\Yithdrav.ial{negative
number).
An
initial
balance
is
entered by the user:
Program
listi
ng:
10
INPUT "INITIAL BALANCE?", B
20 INPUT "TRANSACTION
AMOUNT?",
TA
25
IF
TA
=
0 THEN GOTO 80
30 B=B
+
TA
40
IF
TA<O THEN
GOTO 70
50 PRINT
"DEPOSIT
OF $";TA;
"
POSTED"
60
GOTO
80
70
PRI
NT TA;
" DOLLARS WITHDRAWN"
80 PRINT
"
F INAL BALANCE
=
"; B
90
ENO
47
Do not
sale
this PDF
!!!

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents