The %SCAN built-in function is used to find the start position of the search argument in a string.
If the the search argument isn’t found in the string, result is 0.
%SCAN parameters:
- Search argument
- Source string to search
- Start position for the scan (optional, default 1)
- Length to scan (optional, default the length of the source string)
Example
1 2 3 4 5 6 |
dcl-s locString char(50); dcl-s locFoundPos int(3); locString = 'I drive a Volvo'; locFoundPos = %scan('Volvo' : locString); // The locFoundPos will get the value 11 as Volvo starts in pos 11 in the string locString |