StringLib.GetNextToken function

StringLib.getNextToken returns a token from a substring.

Package

eglx.lang

Syntax
static function getNextToken (source string in, 
                              index int inout, 
                              delimiters string in) 
                returns (string?);
source
Takes a source string.
index
Takes the starting position at which to begin searching for a token, given that the first character in source is at position 1. If a token is found, the value in index is changed to the index of the first character that follows the token. If no token is found, index is set to one plus the length of the source string.
delimiters
Takes a string that contains one or more delimiter characters, with no characters separating one from the next.
Example use

In the following code, source is 20 characters, or 40 bytes:

program MyProgram type BasicProgram{}

   source string = "CALL PROG1 arg1,arg2";
   delimiters string = ", ";
   index int = 1;
   max int;
   tokens string[];
   token string? = "";

   function main()
      max = source.length();
      SysLib.writeStdout("max = " + max);

      while(index < max)
         token = StringLib.getNextToken(source, index, delimiters);

         if(token != null)
            SysLib.writeStdout(token + " <--- " + index);
         end
      end
   end
 end
Here is the output, which tells the change in the value of index:
max = 20
CALL <--- 5
PROG1 <--- 11
arg1 <--- 16
arg2 <--- 21
Comments
Compatibility

Table 1. Compatibility
Target Issue
Java No issues.
JavaScript No issues.