gettoken()

 
Returns the nth number token (i.e. substring) of a delimited_string using characters as token separators. A null string is returned if there is no nth token. Common delimiter characters are comma, tab, linefeeds, pipe but are not limited to these.
Syntax
gettoken( delimited_string, characters, position_num )
Returns the position_num token (i.e. substring) of a delimited_string delimited by characters.
  • delimited_string = A string delimited by a character or characters
  • characters = the delimiter character or characters
  • position_num = the position of the substring you want to return
User Annotations: gettoken
Ray Yates : mivascript at, pcinet d0t com
09/10/2011 21:01 p.m.
Given this pipe delimited string: gettoken('a|b|c|d|e', '|', 3) returns "c"

Where s.tm_mon is a system variable that contains the numeric month of the year (1 to 12) this function will return an abreviation of the current month from the space delimited string.

gettoken('Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec,' ',s.tm_mon)

Sometime it is usefull to know how many tokens are in a string. The GettokenCount() function below can be used to get than number.
<MvFUNCTION NAME = "GettokenCount" PARAMETERS = "text_string, separator" STANDARDOUTPUTLEVEL = "">
    <MvFUNCRETURN VALUE = "{ (len(l.text_string) - len(glosub(l.text_string, l.separator,''))) + 1 }">
</MvFUNCTION>