xHarbour Reference Documentation > Function Reference |
Retrieves the n-th token from a string.
Token( <cString> , ; [<cDelimiter>] , ; [<nTokenPos>] , ; [<nSkipWidth>] , ; [@<cPreTokenSep>] , ; [@<cPostTokenSep>] ) --> cToken
The function returns the token found at <nTokenPos> in a character string. When no more tokens can be found, the return value is a null string ("").
Note: Token() does not use the tokenizer environment. Therefore, TokenInit() does not need to be called. However, when large strings are tokenized, it is recommended to take advantage of the tokenizer environment for achieving best performance.
See also: | AtToken(), HB_ATokens(), NumToken(), TokenInit(), TokenLower(), TokenSep(), TokenUpper() |
Category: | CT:String manipulation , Character functions , Token functions |
Source: | ct\token1.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example extracts all directories from the PATH // environment variable. PROCEDURE Main LOCAL cPath := GetEnv( "PATH" ) LOCAL cDirectory, nCount := 0 // Last token ? Token( cPath, ";" ) // All tokens DO WHILE .T. cDirectory := Token( cPath, ";", ++nCount ) IF Empty( cDirectory ) EXIT ENDIF ? nCount, cDirectory ENDDO RETURN
http://www.xHarbour.com