subSequence()

The strLib.subSequence()system function is used to retrieve a portion of a string. This method takes three parameters: the target string, the starting index (inclusive) and the ending index (exclusive) of the portion of the target string to be retrieved.

Syntax

  strLib.subSequence(
             target STRING | CHAR | DBCHAR | MBCHAR | UNICODE In, 
             startingIndex INT In)
             endingIndex INT In) 
  returns (result STRING | CHAR | DBCHAR | MBCHAR | UNICODE))
target

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

startingIndex

An integer representing the first character (inclusive) of the substring to be retrieved.

endingIndex

An integer representing the last character (exclusive) of the substring to be retrieved.

result

It returns a portion of the original string, starting from the startingIndex and ending with the endingIndex.

Example

 function main()
       myString String      = “Customer”;
       myChar Char(8)       = “Customer”;
       myUni Unicode(8)     = “Customer”;

       sysLib.writeStdout(“‘Customer’ from index 1 to 7 is: “ + strLib.subSequence(myString, 1, 7));
       sysLib.writeStdout(“‘Customer’ from index 6 to 9 is: “ + strLib.subSequence(myChar, 6, 9));
       sysLib.writeStdout(“‘Customer’ from index 7 to 9 is: “ + strLib.subSequence(myUni, 7, 9));
   end

The output is as follows:

   ‘Customer’ from index 1 to 7 is: Custom 
   ‘Customer’ from index 6 to 9 is: mer 
   ‘Customer’ from index 7 to 9 is: er