INDEX finds where the values in VARB1 occur in VARB2. For each item in VARB1
it searches through VARB2 and returns the matching address of the first item.
The MATCHFLAG determines the matching criterion. MATCHFLAG is used slightly
differently depending on whether you are searching for number matches or
character string matches.
For numerical searches, if MATCHFLG is:
0 - only exact matches are found [DEFAULT]
-1 - values less than or equal to VARB1 will match
1 - values greater than or equal to VARB1 will match
For STRING searches, if MATCHFLG is:
1 - only exact matches are found
-1 - if no exact match is found, find VARB1 as subset of VARB2 string
(eg. would find 'wan' in the SLIST example below) [DEFAULT]
2 - if no exact match is found, find VARB1 as superset of VARB2 string
(eg. would find 'sadly' in the SLIST example below)
RANK can be used to help control the search process. It can be a number:
0 - if the items in VARB2 are in no particular order (default)
1 - if the items in VARB2 are in ascending order
2 - if the next item in VARB1 will be at a higher index in VARB2 than the
previous found item (items not found do not affect ranking)
4 - ignore zero items in VARB2
8 - find a match of the entire sequence in VARB1, in VARB2
Or, RANK can be an array variable in which case it should contain the
rank order of elements in VARB2,
Examples: varb1 = { 20 30 20 10 40 40 10 } str1 = "had" slist = {
varb2 = { 10 20 30 40 } str2 = "asdfghjkl;" sad
had
index(varb1,varb2)--> { 1 2 1 0 3 3 0 } wand
index(str1,str2) --> { 5 0 2 } }
index(str1,slist) --> { 1 }