%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})
Required. Must be of type character.
Required. Must be the same type as the first parameter.
Optional. Must be numeric with zero decimal positions.
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.
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