xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

TokenNext()

Retrieves the next token from a string.

Syntax

TokenNext([@]<cString>   , ;
            [<nTokenPos>], ;
           [@<cTokenEnv>]  ) --> cToken

Arguments

<cString>
This is a character string to extract a token from. It is recommended to pass it by reference to achieve maximum performance.
<nTokenPos>
A numeric value indicating the ordinal position of the token to retrieve. It defaults to the current token. If omitted, the token counter of the tokenizer environment is incremented so that a subsequent call to TokenNext() retrieves the next token.
@<cTokenEnv>
Optionally, a character string holding a local tokenizer environment can be passed. It is obtained via the fourth parameter of TokenInit(). <cTokenEnv> must be passed by reference. If <cTokenEnv> is omitted, the function uses the global tokenizer environment.

Return

The function retrieves the next token from a character string prepared for the incremental tokenizer with TokenInit().

Info

See also:RestToken(), SaveToken(), TokenAt(), TokenInit()
Category: CT:String manipulation , Character functions , Token functions
Source:ct\token2.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example lists all directories from the PATH environment variable

   PROCEDURE Main
      LOCAL cPath  := GetEnv( "PATH" )
      LOCAL nCount := 0

      TokenInit( @cPath, ";" )

      DO WHILE .NOT. TokenEnd()
         ? ++nCount, TokenNext( @cPath )
      ENDDO

      TokenExit()
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe