Locates a substring within a dynamic array element.
FINDSTR char-string IN dyn-array{,occurrence} SETTING attr-var{,val-var{,subval-var}} [THEN statement(s) | ELSE statement(s)]
char-string is the string to search for within an element in the dynamic array; expressed as a variable or symbol name, a numeric or string literal, or a dynamic array reference.
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 FINDSTR is successful. The ELSE clause is executed otherwise.
If the ELSE clause is taken, variables attr-var, val-var, and subval-var do not change.
ARRAYX = "ALABAMA^CALIFORNIA^MINNESOTA" FINDSTR "CA" IN ARRAYX,1 SETTING Y ELSE PRINT "NO 'CA'"; STOP
Finds the attribute (2) containing substring value CA in dynamic array ARRAYX. Sets Y to a number indicating the position of that attribute, in this case Y=2. Prints an error message if not found.
Note: In the above example, the attribute mark is represented by a caret (^). However, if you were entering this example in a program, it would not compile as shown.
To compose the array so that it will compile:
For example:
EQU AM TO CHAR(254) ARRAYX = "ALABAMA:AM:CALIFORNIA:AM:MINNESOTA"
OPEN "FILE1" TO FILE ELSE PRINT "CANNOT OPEN"; G 10 READ NUM FROM FIL,"1" ELSE PRINT "CANNOT READ"; G 20 FINDSTR 33 IN NUM,1 SETTING K ELSE PRINT "NOT FOUND"; STOP PRINT K
Searches for substring 33 in NUM, item 1 and prints a number representing the location in array NUM where 33 occurs.