Professional Documents
Culture Documents
LOCATE and FINDSTR Functions
LOCATE and FINDSTR Functions
Posted by Marc
LOCATE Function
When searching for a value in an array, you can use the common “LOCATE” function.
You need to specify the dimension of the array, considering that you’re looking for a
string in a:
Note:
– if the searched value is found, variable “POS” indicates the position in the array
(after the “THEN”)
– if not found, “POS” indicates the next position immediately available in the array
(after the “ELSE”), e.g. dimension of the array +1.
Example 1:
...
END
...
END
Example: You have to find a constant that may be PMUF or PMPR or anything else
looking like “PM…” in the array R.NEW(SW.AS.TYPE)
SCHED.TYPES = SUBSTRINGS(R.NEW(SW.AS.TYPE),1,2)
END
Example:
YY.OR.MED.FM = ''
YY.OR.MED.VM = ''
YY.OR.MED.SM = ''
FINDSTR searched_value IN array SETTING YY.OR.MED.FM, YY.OR.MED.VM,
YY.OR.MED.SM ELSE YY.OR.MED.FM = “”
IF YY.OR.MED.FM THEN
...
END
You just need to adapt the correct data separator, depending on the structure of
the ARRAY.