EasyManua.ls Logo

Husky Hunter - Page 303

Husky Hunter
499 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...
BASIC FUNCTIONS
SECTION 5.20
SRCH
5.20. 9 Function SRCH function enables an array to be searched for the
occurrence of a specified element within that array.
Syntax SRCH( <array element>, <numerical expression>)
The array element specified is used as the reference to be
searched for in the remaining array.
Examples PRINT SRCH(A$)
A=SRCH(A(5),3)
ff SRCH(A!(O), 1 )<>5 THEN OPCHR7
Remarks Consider the following program.
10 DIM A$(10,20)
VER.V09F
20 A$(0 )=
11
ABCDE
11
30 A$( 1 )= "AB"
40 A$(2 )=
11
ABCDE
11
50 A$(3 )=
11
ABCDE
11
60 A$(4 )=
11
ZXYZ
11
70 A$(5)=
11
ABCDE
11
100 INPUT X,Y
110 PRINT SRCH(A$(X),Y)
120 GOT0100
When found the element number is returned. If not found
then zero is returned.
The function searches from the specified element to the end
of the array. As an option, up to 255 occurrences can be
checked for by specifying in the argument the number of
repeat occurrences.
If this value is 256 or larger a syntc1x errcr will occur.
The result of SRCH is a numeric value which can be used in
arithmetic expressions etc.
The search function can al.so be used on simple or double
precisior, arrays.
The following are the results of :oearch on the above array:
SRCH(M) gives 2 : as element (2) is the first
PAGE 5 - 134