lastIndexOf()

The strLib.lastIndexOf()system function returns the index of the last occurrence of a specified value (substring or element) within the string. If the value is not found, it returns -1.

Syntax

  strLib.join(
             target STRING | CHAR | DBCHAR | MBCHAR | UNICODE In, 
             element STRING | CHAR | DBCHAR | MBCHAR | UNICODE In)
  returns (result BOOLEAN)
target

Input can be any value that is assignment compatible with any of the above types.

delimiter

Input can be any value that is assignment compatible with any of the above types.

result

It returns an int representing the index of the last occurrence of the specified value element within the string. The following values for result have a special meaning:

0

The element was not found within the string.

Example

    function main()
       myString String       = “Customer department service”;
       elementStr String     = “e”;
       myChar Char(27)       = “Customer department service”;
       elementChar  Char(1)  = “w”;

       sysLib.writeStdout(“Last index of ‘e’ in ‘myStr’ is: “+ strLib.lastIndexOf(myStr, elementStr)); 
       sysLib.writeStdout(“Last index of ‘w’ in ‘myChar’ is: “+ strLib.lastIndexOf(myChar, elementChar));
   end

The output is as follows:

   Last index of ‘e’ in ‘myStr’ is: 27 
   Last index of ‘w’ in ‘myStr’ is: 0