A
ll
and more about Sharp
PC
-1
500
at
http://www.PC-1500.info
PR
INT
US
I
NG
.,
:::
::
t,
;:
~
~,
;;:
:t:
~
":
246813
246,
813
No
te:
Us
e the number
of
~
(including * ) marks for variable (integer)
des
ignation in the
following
range:
Wi
th
a 3·digit punctuat
io
n ( , J
no
t used: With in
11
{including sign)
W
it
h a 3·dig
it
punctuation ( , J
used
:
Within
14 (includi
ng
sign)
T
hi
s
co
mputer
has
10
signifi
can
t d igits
for
the
numb
ers.
When the format exceeding 10 integ
ers
is designated
by
the USING statement and
the figure exceeding
10 integers
is
displayed (print<'d) by the PRINT {LPRINT)
statement. the displayed (printed) number may
be
incorrect.
Example: RUN mode Display
U
SING"
~
f.
Ii;;
Ii
;; ;;
~
;;
;;
;;;
;;
::
~
" l<•T
tR
I
_.,
>
PRINT 888888888888 l
'•re•
I - 888888888800
( LPRINT 888888668866 l•
•m•
I - 68888888880 l
12digits
E.
Computed
Control
Transfer
In addi
tion
to
the basic control statemen
ts
described
in
Chapter
II
I,
the
PC
-1500 provides
two
other
control
statements
of
gr
ea
t
ut
i
lity.
These are the ON GOSUB and the
ON
GOTO. As you
might guess
fr
om
their names, these statements act li
ke
the GOSUB and GOTO
stateme
nts
discussed previous
ly.
The difference, ho\vcver, li
es
in
their ability to trans1er control {i.e . to
execu
te statements
at
a different location) automat
ically,
That
is,
the
GOTO
or-
GOSUB
fu
nctions
wi
ll
"GO" to
one
of
several stat
ements
(or
subroutines) depending on
th
e value
of
a
nume(
iC
variable.
This dependen
ce
on
a va(i
ab
le f
or
guidance is what gives
the
ON
st
atements the
nickname
"compu
t
ed
contro
l s
ta
tements".
The ON statcmen ts
have
the form:
ON
ex1Pres
sion l
GOTO
GOSUB
line:;l
l,
li
n
e#2
, linel<3,
...
{etc)
The
exp
res
sion
whi
ch
follows t
he
ON
key1,v-0rd
must
evaluate
to
a positive integer greater than
z
ero
and
le"
than
th
e number
of
line·numbers l isted
alter
t
he
GOTO
or
GOSUB keyword. During
execution,
v.rhen
the
computer
encounte
rs
an
ON
statement,
it tra
nsf
ers
the
fl
oi,•1
or e
xecution
to
the
l
i
ne
·
num~r
which corresponds
to
t
he
value
of
the expression.
A typical
ON
statement mig
ht
be
:
ON
TX
GOSUB 100. 200, 250,
300
In this
case
,
the
variable
TX
MUST contain a number
in
the range 1 through 4
b<lcause
there
are
only
four linc·
numbe
rs listed.
Any
other
number in TX will result i
1'
an
er
ror si
nce
there is
no
corresponding
line
·number. For this reason,
it
is
important
to
include suffici
ent
tests tlF sta
te·
ments
)
to
insure that
your
exp
ressions re.suit in
.a
val id number.
The ON s
tat<ements
are
very
use
f
ul
for
au
tomat
i
ng
a
se
ries
of choi
ces.
For example, consider
the
fo
llowing program fragment
11o1h
i
ch
allows
the
user
to
select
one
of
seve
ral
tax-tabl
es
. Without
lhc
ON statement
this
might
be
written:
83
Do
not sale this PDF
!!!