A
ll
and more about Sharp
PC
-1
500
at
http://www.PC-1500.info
The
fi(St argu1nent
to th
is fur1ction is a cha(aCttP.(
string
or
a
charact
er
str
i
ng
va.riable.
The
sec
o
nd
argument
is a
numbe
r repr
esen
ting
the
first
charact
er
to
be e:xtracted. T
he
th
ird
argu
ment
is
the
tota
l
number
of
c
hara
c
ters,
inc
lud
i
ng
the
fi
rst,
to
be
ext
ra
cted.
In the fi
rst
example,
"I
NEED
HELP"
is stored
in
AS.
MIDS
extracts four characters beginning
at
the third,
and
places t
hese
into
SS.
When
6$
is printed, it is found
to
conta
in
"NEED''.
In the second example, a string
co
nt
aining a telephone number
is
the first argument. The s
ix
th
character
("7")
is located and, together with t
he
following two characters,
is
stored
in the
va
riable
TS.
Wh
en
print.cd. the result
is
"
743".
C.7. RIGH
T$
The
RIGHT$
function works much li
ke
LEF
TS. the only
diffe
r
ence
be
ing
that
it starts
from
the opposite
(right}
end of the string. The arguments arc the
same
as
LEFTS:
RIGHT$
("
character
string"
, n
umbe
r)
( character variable,
nu
mber)
The
"numbe
r"
argumen
t to
th
is
fun
cti
on
specifies
h
ow
many
ch
arac
ters
to
ex
tract
from
the
c
hnrac
t
cr
string
bcginn
i119
on
th
e r
ight
side
.
Example 1:
10
XS
=
"READ
ONLY
MEMORY"
20
YS = RIGHTS (XS.
6)
30
PRINT
Y$
In this pr
ogram
th
e RIGH
TS
functio
n
takes
six
c
haracter
s
from
the
right
end
of
the
string
and
stores them in t
il
e
va
riable YS. T
he
co
ntent
of
YS
is
now
"MEMORY".
C.8.
RND
There
ll
'1
ay
be ti
mes
\•;1
hen
you
want
to
provide
your
program
\V
i
th
random n·umbers. The
RNO
functions
a
llow
s
the
computer
to
generate
r
ando
m
nurnbers
in a r
ange
fr
om
one
to
a
specif
i
ed
nurn
ber.
{N
ote
: The range al\va
ys
starts
•tJith or
le)
Example 1:
10 A = AND 5
In this
ex
a
mp
le A
cou
ld have any
one
of
the
values
one
thr
ough
five,
inc
lusive.
If
you
,.vant
ran
dom
.
nu
1nbers in a
range
whii;h begins
\Y
i
tlh
a
number
oth
er
than
1, (f
or
example
40
to
50}
you
w
ill
have
tu
si
mu
la
te
this
by
generating
ra:
ndom
numbcrs
·
from
1 to
10
and
adding
a
constant
(39
in
ou
r example}:
Example
2:
10
FOR I = 1 TO 5
20
B =
40+RND
10
40
PR
INT B:
50
N
EXT
I
Output
:
[
42
AUN
; I
44
47
48
42
77
Do
not sale this PDF
!!!