%SCANR returns the last position of the search argument in the source string, or 0 if it was not found.
Syntax:
%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.
Example:
path = ‘/home/mydir/newfolder/example.txt’;
lastSlash = %SCANR(‘/’ : path);
if lastSlash = 0;
fileName = path;
else;
fileName = %subst(path : lastSlash + 1);
endif;
lastSlash = 22
fileName = ‘example.txt‘
Great web site. A lot of useful information here. I am sending it to several friends ans also sharing in delicious. And of course, thank you on your effort!