FIND

FIND

Top  Previous  Next

 

The FIND statement searches a dynamic array for a given string in any position.

 

 

Format

 

FIND string IN dyn.array {, occurrence} {SETTING field{, value {, subvalue}}}

{THEN statement(s)}

{ELSE statement(s)}

 

where

 

stringevaluates to the item to be located.

 

dyn.arrayis the dynamic array in which searching is to occur.

 

occurrenceis the occurrence of string to be found. If omitted, the first occurrence is located.

 

fieldis the variable to receive the field number at which string is found.

 

valueis the variable to receive the value number at which string is found. If omitted, only the field position is returned

 

subvalueis the variable to receive the subvalue number at which string is found. If omitted, only the field and, optionally, value positions are returned

 

statement(s)are statements to be executed depending on the outcome of the FIND action.

 

At least one of the THEN and ELSE clauses must be present.

 

 

The FIND statement searches dyn.array for a field, value or subvalue equal to string. If found, the position of string within dyn.array is returned in the field, value, and subvalue variables and the THEN clause is executed. If not found or dyn.array is a null string, the field, value, and subvalue variables are unchanged and the ELSE clause is executed.

 

Use of the $NOCASE.STRINGS compiler directive makes the comparison case insensitive.

 

 

Example

 

Variable X contains AFMBVMCVMDFMEVMFSMG

 

FIND 'D' IN X SETTING F, V, S

 

The above FIND would return F = 2, V = 3, S = 1

 

 

See also:

DEL, DELETE(), EXTRACT(), FINDSTR, INS, INSERT(), LISTINDEX(), LOCATE, LOCATE(), REPLACE()