Then; Goto - Sharp PC-1500A Instruction Manual

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

Advertisement

All
and
more
about Sharp PC-1500
at
http://www.PC-1500.info
Several endings are
not the result
of good programming
practice.
Our
reversal
of
these
statements
does
demonstrate
though, that
correct ordering of statements
and
proper testing
are
necessary
fo
r
a program
to
operate correctly.
In the
next section,
we will observe
a
third
way
to
phrase our
program which
involves
the
GOTO
statement and solves the problems
of the
second version.
Although the condition of an IF statement
is usually
an inequality,
it is
not
necessarily so. In
PC·1500A BASIC any
expres.sion
which
evaluates
to non.zero
is
considered
to
be
True. Any
expres.sion which
evaluates to
zero
is
considered to be
false.
This
explains
why
inequalities
work
as
conditions:
remember
that an
inequality
whichi
is
True returns
a 1
and
inequalities
that
are
False return a 0.
One
more
reminder
is
in order.
If
the
statement which
folloi.vs the
T
HEN
is an
assign1nent
statement, the LET keyword
MUST
be
used. Failure
to do
so
will cause an ERROR condition
to
occur.
This
was dis.cussed
in
the section on
the LET
S1atcment.
Caution
: Refer
to page
164.
0. GOTO
You may have noticed.
in
the last section, that our
options
.. vere limited
after
the test
was
made
in
the
IF
statement.
We \vere only
allowed
to
execute
one statement
if
the
cond ition
was
True.
For conven ience, w
e
would
like
to
execute
several statements.
The
GOTO
statement allO\\IS us
to
do
this.
The GOTO statement modifies the "flow" of
suatcmcnt
execution.
It tells
SHARP to
"
go
to"
a
line other than the
next
one and begin executing statements sequentially
from there.
The
effect of
this
"jump"
is that
some statements may be skipped entirely. For example review
the
following program:
Program
Listing:
10
PAUSE
"ESCHEW ";
20 GOTO
50
30 PRINT X*3/4+2
40
PRINT "A
BOOK WHICH EMPLOYS";
50
PR
INT
"OBFUSCAT
ION!"
60
ENO
Keystrokes:
m
oo
rn
CID
rn
C9J
rn oo
1
.,
••
1
rn rn
mm
co oo rn m rn co
mm
G..J
m
1
...
..
1
f4J
rn m
rn
co
CID
rn
1SH•"1
CJ
oo
t•••c•1
oo
CID OD
rn
1 •••c•1
oo rn
co
m ao
1
....
c,1
m
CEJ
mm
OD
m
rn
1SHIFT
1
C:J
1SH•FT
1
m
1
F.NTERI
m oo
m rn rn
CID
co
1
......
1
r::::J
oo
oo
m oo
rn
m
m
C!:JC:O
[][JQD ISHIFT!
CD
l
>••n
l
c:::J
l•HTE•
I
rn mm
CID
oo
1
.....
,
46
Do not sale this PDF
!!!

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents