And 5 - Sharp PC-1500 Instruction Manual

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
The
fi(St
argu1nent
to
this
fur1ction is
a
cha(aCttP.( string
or
a
characte
r
string va.riable. The
seco
nd
argument is a
number
rep
resent
ing
the first
character
to
be
e:xtracted. The
th
ird
argument is
the
total
number of characters, including the
fi
rst,
to
be extracted.
In the f irst
example,
"I NEED
HELP"
is
stored
in
AS.
MIDS
extracts
four
characters beginning
at the third, and places these into
SS.
When
6$
is
printed,
i
t is
found to
contain
"NEED''.
In
t
he second
example
,
a
string containing
a
telephone
number
is
the
f
irs
t
argument.
The sixth
character
("7") is
located
and
,
together
with
the following two
characters,
is
stored in the
variable
TS.
When print.cd. the result is
"
743".
C.7.
RIGHT$
The RIGHT$ function
works
much
like
LEF
TS.
the only difference
bei
ng that
i
t
starts
from
the opposite (right} end
of
the string. The arguments
arc
the
same
as LEFTS:
RIGHT$
("ch
aracter
string",
n
umber)
(
character
variable,
number)
The
"number
" argumen
t
to
this
fun
c
tion
specifies
h
ow many
charact ers
to
extract from
the
c
hnract
cr string
bcginni1 19
on
the
right
side.
Example 1:
10
XS
=
"READ ONLY MEMORY"
20
YS
=
RIGHTS (XS.
6)
30 PRINT Y$
In
this p rogram
the R IGHTS
functio
n
takes
six
characters
from
the right end of the s
t
ring
and
stores them in
t
ile
variable
YS.
The
con
tent
of YS
is
now
"MEMORY".
C.8.
RND
There
ll' 1
ay
be
ti
mes \•;1hen
you want
to
provide your
program
\Vith
random n·umbers
. The
RNO
functions
allows
the computer to generate
random
nurnbers
in
a
range
fr
om
o
ne
to a
specified
nurn
ber.
{Note
:
The range a l\vays starts
•tJith o rle)
Example 1:
10
A
=
AND 5
In this exa mple
A
could
have
any
one of the
values
one through
five,
inclu
sive.
If
you ,.vant
random.
nu1nbers
in
a range
whii;h
begins
\Yitlh
a number
o ther
than
1, (for
example 40 to
50}
you
will
have tu
s imulate
this by generating ra:ndom numbcrs·from
1 to
10
and adding a constant
(39 in
ou
r
example}:
Example
2:
10
FO
R
I
=
1
TO 5
20
B
=
40+RND
10
40
PR INT
B
:
50
NEXT I
Output
:
[
42
AUN
;
I
44 47
48
42
77
Do not
sale
this PDF
!!!

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents