EasyManua.ls Logo

Radio Shack TRS-80 Model III - Page 178

Radio Shack TRS-80 Model III
274 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
TRS-80
MODEL III
MID$ (string,p,n)
Returns a substring of string with length n
and starting
at
position/?.
The string
name, length and starting position must be enclosed
in
parentheses, string may be a
string
constant
or expression, and
n andp
may be numeric expressions or constants
.
For example,
MID$
(L$,3,1) refers to a
one-character string beginning with
the
third
character of L$.
If no argument is specified for the length n
,
the
entire string beginning
at position
p
is returned.
Example Program:
The first three digits of
a
local phone number are
sometimes called
the "exchange'
'
of the number. This program looks at
a
complete phone
number
(area code,
exchange, last four digits) and picks out the exchange of that number.
800 INPUT "AREA CODE AND
NUMBERS (NO HYPHENS?
PLEASE)"; P*
810
EX*
=
MID* <P*»
4,3)
820 PRINT "NUMBER
IS IN
THE
"
?
EX*?
"
EXCHANGE."
RIGHTS
(string,
n)
Returns
the last n characters of string
.
string and
n
must
be
enclosed in
parentheses
.
string may
be a string constant
or
variable, and n may be a numerical
constant or
variable
.
If
LEH(string) is less than
or equal to n, the
entire string
is returned
.
10
INPUT
"ENTER
A WORD"?
M*
20 IE LEN<M*>
=
THEN
10
30 PRINT "THE LAST LETTER WASs
»
; RIGHT*(M*»1)
40 GOTO
10
STR$
(expression)
Converts a numeric
expression
or constant to a string. The numeric
expression
or
constant must
be enclosed in parentheses.
STR$(A), for example,
returns a string
equal to the
character representation
of the value of
A.
For
example , if
A
=
5 8 .
5
,
then
STR$(A) equals
the
string
"
58.5"
. (Note the
leading
blank in
"
58.5").
While
arithmetic
operations may
be performed on
A,
only string
operations
and functions
may be
performed on
the string
"58.5".
PRINTSTRS(X) prints
X without
a trailing blank; PRINTX prints
X with a trailing
blank.
168

Other manuals for Radio Shack TRS-80 Model III

Related product manuals