%SCANR returns the last position of the search argument in the source string, or 0 if it was not found.


%SCANR(search argument : source string { : start { : length } } )

%SCANR is similar to %SCAN. They differ only in the direction of the search

• The “start position” represents the beginning of the substring to be searched

• %SCANR starts at the end of the string and searches backwards until it finds a match or it reaches the start position •

The start and length parameters represent a substring in the source string. The “start” parameter doesn’t indicate the starting position for the search.


path = ‘/home/mydir/newfolder/example.txt’;

lastSlash = %SCANR(‘/’ : path);

if lastSlash = 0;

fileName = path;


fileName = %subst(path : lastSlash + 1);


lastSlash = 22

fileName = ‘example.txt‘