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>
- 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 TE
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 TE
- Status
- Ready
- Compliance
-
- TOKENAT() is compatible with CTIII'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.
- See Also