RAT( ) example
Here is a simple file name extraction function that extracts a file name for a path by looking for the last backslash character with RAT( ). Everything that follows in the string is extracted with SUBSTR( ). If there is no backslash, the entire string is returned.
? getFileName( "C:\\WINDOWS\\SOL.EXE" )
function getFileName( cArg )
local nPos
nPos = rat( "\", cArg )
return iif( nPos >= 0, substr( cArg, ++nPos ), cArg )
Note that the position returned by RAT( ) is incremented before it is passed to SUBSTR( ). Otherwise, the last backslash would be returned as well.