getNextToken

getNextToken(int: Integer io): String;

The getNextToken method of the String primitive type returns the next token in the receiver; that is, it returns the string from the current value of the int parameter to the next delimiter.

As the String::scanUntil method (which supersedes this getNextToken method) provides increased functionality and flexibility, you may want to use that method instead.

The string delimiter can be any of the following characters.

To define the position from which the next delimiter is returned, specify the starting position in the int parameter in a method.

The following example shows the use of the getNextToken method.

vars
   str   : String;
   token : Integer;
begin
   str   := 'this:is/a;string';
   token := 1;
   write str.getNextToken(token) & ' ' & token.String; // Outputs 'this 6'
   write str.getNextToken(token) & ' ' & token.String; // Outputs 'is 9'
   write str.getNextToken(token) & ' ' & token.String; // Outputs 'a 11'
   write str.getNextToken(token) & ' ' & token.String; // Outputs 'string 17'
end;

The getNextToken method returns null when the end of string is reached.