EasyManua.ls Logo

Radio Shack TRS-80 Model 3 - Page 178

Radio Shack TRS-80 Model 3
276 pages
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
p.
The string
name, length and starting position must be enclosed in parentheses.
string may be a
string constant
or
expression, and
nand
p may be numeric expressions or constants.
Forexample,
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 positionp
is returned.
Example Program:
The first three digits
of
a local phone numberare 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
EXS
=
MIDS
(PS,
4,3)
820
PRINT
"NUMBER
IS
IN
THE
";
EX$; "
EXCHANGEd"
RIGHT$(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.
IfLEN(
string) is less than orequal to n, the entire string
is
returned.
1(lI I
NPU'r
II
E:N"rER
li
l..,IOF<n
II;
IVI<~,
20
IF
LEN(MS)
= 0
THEN
10
:30
PR
I
N'r
II
THE
L..f.~s'r
LE::T'TER
It',I,<~E;
~
'+0 GO'rO 1
'j
STR$ (expression)
II;
RI
GH"r~;
(
IVI~~;
OJ
:I.
)
Converts a numeric expression
or
constant to a string. The numeric expression or
constant must beenclosed in parentheses.
STR$(A), for exarnple, returns a string
equal to the characterrepresentation
of
the value
of
A. Forexample,
if
A =
58.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" .
PRINTSTR$(X) prints X without a trailingblank; PRINTX prints X with a trailing
blank.
5/6

Related product manuals