TOKENAT()
Get start and end positions of tokens in a token environment
Syntax
TOKENAT( [<lSeparatorPositionBehindToken>], [<nToken>], [<@cTokenEnvironment>] ) -> nPosition
Arguments
<lSeparatorPositionBehindToken> .T., if TOKENAT() should return the position of the separator character BEHIND the token. Default: .F., return start position of a token.
<nToken> a token number <@cTokenEnvironment> a token environment
Returns
<nPosition> See description
Description
The TOKENAT() function is used to retrieve the start and end position of the tokens in a token environment. Note however that the position of last character of a token is given by tokenat (.T.)-1 !!
If the 2nd parameter, <nToken> is given, TOKENAT() returns the positions of the <nToken>th token. Otherwise the token pointed to by the TE counter, i.e. the token that will be retrieved by TOKENNEXT() _NEXT_ is used.
If the parameter <@cTokenEnvironment> is supplied (must be by reference), the information from this token environment is used, otherwise the global TE is used.
Tests
tokeninit( cString ) // initialize a token environment DO WHILE ! tokenend() ? "From", tokenat(), "to", tokenat( .T. ) - 1 ? tokennext( cString ) // get all tokens successivly ENDDO ? tokennext( cString, 3 ) // get the 3rd token,
// counter will remain the same tokenexit() // free the memory used for the
// global token environment
Compliance
TOKENAT() is compatible with CT3’s TOKENAT(), but there are two additional parameters featuring local token environments and optional access to tokens.
Platforms
All
Files
Source is token2.c, library is libct.
Seealso
TOKENINIT(), TOKENEXIT(), TOKENNEXT(), TOKENNUM(), SAVETOKEN(), RESTTOKEN(), TOKENEND()
Pingback: Harbour String Functions | Viva Clipper !
Pingback: Harbour All Functions – T | Viva Clipper !