Tandy 1000 Basic Reference Manual page 187

Hide thumbs Also See for 1000:
Table of Contents

Advertisement

Chapter 10 I
BASIC
Keywords
INSTR
Function
Searches for the first occurrence of
string2
in
stringl
and re-
turns the position
at
which the match is found.
Number
specifies the position in
stringl
to begin searching for
string2. Number
must be a n integer in the range 1 to 255. If you
omit
number,
INSTR starts searching a t the first character in
stringl
.
If
BASIC finds
string2
in
stringl,
it returns the starting position
of the match; otherwise, it returns zero. If the entire substring
is not contained in the search string, BASIC returns a zero.
Examples
Suppose A$
=
"LINCOLN"
Statement
BASIC returns
INSTR(A$, "INC")
2
INSTR(A$, "12")
0
INSTR(A$, "LINCOLNABRAHAM")
0
For a slightly different use of INSTR, try:
1 0
X = I N S T R
( 3 ,
" 1 2 3 2 1 2 3 " ,
" 1 2 " )
20 P R I N T
X
which p r i n t s 5, because t h e search s t a r t e d a t t h e t h i r d
character.
185

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents