| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Returns the start and end position of a token.
TokenAt( [<lNextDelimiter>], ;
[<nCount>] , ;
[@<cTokenEnv>] ) --> nPosition
The function returns either the position of the token found with TokenNext() (default) or the position of the following delimiter as a numeric value.
| See also: | TokenInit(), TokenNext() |
| Category: | CT:String manipulation , Character functions , Token functions |
| Source: | ct\token2.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example determines the start and end position of the second
// token in a string and extracts it with function SubStr().
PROCEDURE Main
LOCAL cIPAddr := "189.88.3.256"
LOCAL cTokenEnv, nStart, nEnd
TokenInit( cIPAddr, ".", @cTokenEnv )
? nStart := TokenAt( .F., 2, @cTokenEnv ) // result: 5
? nEnd := TokenAt( .T., 2, @cTokenEnv ) // result: 7
? SubStr( cIPAddr, nStart, nEnd-nStart ) // result: 88
RETURN
http://www.xHarbour.com