Locates the position (attribute, value or subvalue) of a string or value in a dynamic array.
FIND value IN dyn-array{,occurrence} SETTING attr-var{,val-var{,subval-var}} [THEN statement(s) | ELSE statement(s)]
value is the string or value being searched for expressed as a variable or symbol name, or a numeric or string literal.
dyn-array is the name of the dynamic array in which to search.
occurrence is the number of the occurrence of the element being searched for in dyn-array.
If occurrence is not specified, it defaults to 1.
attr-var is a variable that is set to the attribute position where the element is found.
val-var is a variable that is set to the value position where the element is found.
subval-var is a variable that is set to the subvalue position where the element is found.
statement(s) is either a THEN or ELSE clause (or both). A statement must be included. The THEN clause is executed if the FIND is successful. The ELSE clause is executed otherwise.
The FIND statement works the same way as the LOCATE statement, except it does not require a specific format for the dynamic variable.
FIND returns the attribute and, if specified, the value and subvalue in which the element is found.
DYNARR = "A^B^C^D^E^F^G^A^B^C" FIND "A" IN DYNARR,2 SETTING X ELSE PRINT "NOT FOUND"; STOP
Finds the second occurrence of the element A in dynamic array DYNARR. Sets X to a number indicating the position of that attribute. In this example, X = 8 (the second occurrence of A in DYNARR is its eighth atribute).
ITEM = "24^34]28]31^29]22]21" X=29 FIND X IN ITEM,1 SETTING A,B ELSE PRINT "NOT FOUND"; STOP PRINT A,B
Finds the multivalue equal to 29 in attribute A, value B and prints A and B. In this example, A=3 and B=1.
ARR = "44^88^6]2]7\3\2^8^99" FIND 3 IN ARR,1 SETTING A,B,C ELSE PRINT "CAN'T FIND"; STOP PRINT A,B,C
Finds numeric literal 3 in attribute 3, value 3, subvalue 2 of dynamic array ARR and prints the contents of A, B and C (3, 3 and 2).
Note: In the above examples, the attribute mark is represented by a caret (^). However, if you were entering any of the examples in a program, they would not compile as shown. To compose the array so that it will compile:
For example:
EQU AM TO CHAR(254) DYNARRAY = "A]B]C]D":AM:"E]F]G]H":AM:"I]J"