MID$
Function
MID$(string, integer [,numberĀ»
Returns a substring of string, beginning at position integer.
If
integer
is
greater than the number of characters
in
string, MID$
returns a null string.
Number is the number of characters
in
the substring. If omitted,
BASIC returns all right most characters, beginning with the character
at position
integer.
Examples
If
A$ = "WEATHERFORD" then
PRINT
MID$(A$,
3,
2)
prints
AT.
F$
= MID$(A$,
3)
puts ATHERFORD into
F$.
Sample Program
200
INPUT
"AREA
CODE
AND
NUMBER
(NNN-
NNN-
NNNN)
"j
PH$
210
EX$
= MID$(PH$,
5,
3)
220
PR
I
NT
"NUMBER
I
SIN
THE
" D($ "
E){CHANGE."
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.
2-129