Sharp PC-1500A Instruction Manual page 85

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

Advertisement

All
and more about Sharp
PC-1500
at http:/lwww.PC-1500.info
PRINT
USING
"""
......
..
-
-,
;;:
;;: ;;:
'
= = =
"' ;
246813
2
4
6. 8 1 3
I
Note
:
Use th
e
number
o
f
~
{including
*
I marks fo
r variab le
(in teger)
designation in the
following range:
With
a 3·digit
punctuation
(
,)
not
used:
Within
11
(including sign)
With
a
3-0iglt
punctuation
(,I
used:
Withi
n
14
(including
sign)
Th is
computer
has
1 O significant
digits
for the numbers.
When the format
exceeding
10
integers is
designated by
the
USING statement
a
nd
the figure exceeding 10
integers
is displayed
(pr
inted) by the PRINT
{LPRINT)
statement, the
displayed (printed) number may be incorreet.
Example:
RUN mode
Display
US
I
NG'·~#
::t
~:;:::;:,::::::
:: :: :;:
~
..
IENT£RI
-.
>
PR
INT
888888888888
l<•
n•l
( LP
RIN
T 888888888888
1•••••1
12
d igits
E. Computed Control Transfer
-
888888888800
-+
88888888880
)
In addition
to
the basic
control
statements
described in Chapter
Ill. the
PC·1500A
provides
two
other
control statements
of great utility.
These are the
ON GOSUB
and the ON
GOTO. As
you
m ight
guess
from their
names,
these
sta
tements
act
like the
GOSUB a
nd GOTO
statemen ts
discussed previous ly
.
The
difference, howeve
r,
lies
in
their
abili
ty to transfer con trol
(i.e.
to
execute
statements
at
a
different location) auto
matically. That is,
the GOTO or
GOSUB fu
nctions
will "GO"
to
one
ot several
statements
{or subrou
tines) depending
on the
value of a
numeric
variable.
This
dependence
on a variable for
guidance is
what
gives
the ON
state"'ents
the
nickname
..
computed
control
statements".
The ON
statements
have
the
form:
ON expression
l
GOTO
GOSUB
line
ii
1.
line
ll2,
line
113, .
.
.
(etc)
T he
exp(essiol'I
which
follows the
ON keywo(cJ
must
evalua
te
to a
positive integer greater
than
zero
and less t
h
an the number
of
line·numbers listed after the GOTO or GOSUB
keyword.
Our
ing
execution,
when t
he
computer
encounters an ON
statement. it transfers
the flow or execution
to
the
line.number
which
corresponds to the value
of
the
expression.
A
typical
ON
statement
might
be:
ON
TX GOSUB 100, 200,
250. 300
In this
case.
the
variable
TX
MUST
contain
a
number in the range 1 through 4 because
th•lre are
only
four line-numbers
listed
.
Any other
number in TX will
result in
an
error
since
there
is no
corresponding
line·number.
For this
reason,
it is important
t
o
include
sufficient
tests (IF state·
ments) to
insure
that
your expressions result
in
a
valid number.
The ON statements
arc very
useful for
automating a series
of
choices.
For
example.
consider
the following program fragment whid:i
allows
the
user
to
select one of
several tax
tables.
Without
the ON statement this migit
be
written:
Do not
sale
this PDF
!!!
8
3

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents