%SCAN Function
%SCAN built-in function returns the first position of the search argument in the source string, or 0 if it was not found. If the start position is specified, the search begins at the starting position. The result is always the position in the source string even if the starting position is specified. The starting position defaults to 1.
*<pos>* = %SCAN (SearchArgument, SourceString, {Start})
Parameters
SearchArgument
Required. Must be of type character.
SourceString
Required. Must be the same type as the first parameter.
Start
Optional. Must be numeric with zero decimal positions.
Returns
***
Remarks
When any parameter is variable in length, the values of the other parameters are checked against the current length, not the maximum length.
This built-in function can be used anywhere that an unsigned integer expression is valid.
Unlike the SCAN operation code, % SCAN cannot return an array containing all occurrences of the search string and its results cannot be tested using the %FOUND built-in function.
Example
BEGSR Scan_Ex
DclConst Name(Source) Value("This is a test.")
DclFld Name(Pos) Type(*ZONED) Len(5,0)
Pos = %Scan ("est", Source, 5)
Msgbox Pos
ENDSR