xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

AtToken()

Returns the position of the n-th token in a string.

Syntax

AtToken( <cString>    , ;
        [<cDelimiter>], ;
        [<nCount>]      ) --> nPos

Arguments

<cString>
This is a character string to find a token in.
<cDelimiter>
This character string holds a list of characters recognized as delimiters between tokens. The default list of delimiters consist of non-printable characters having the ASCII codes 0, 9, 10, 13, 26, 32, 138 and 141 and the following punctuation characters: ,.;:!?/\<>()!HSH&%+-*
<nCount>
A numeric value indicating the token to retrieve the position for. It defaults to the last token.

Return

The function returns the position of the <nCount>th token within <cString> as a numeric value, or zero when no more tokens exist. A token is a sequence of characters in <cString> delimited with one or two characters of <cDelimiter>.

Info

See also:HB_ATokens(), NumToken(), Token(), TokenLower(), TokenUpper()
Category: CT:String manipulation , Character functions , Token functions
Source:ct\token1.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example displays substrings extracted from a
// tokenized string

   PROCEDURE Main
      LOCAL cDate := DtoC( StoD( "20061231" ) )
      LOCAL cTime := Time()
      LOCAL cFile := "Test.prg"

      ? cDate                                  // result: 12/31/06
      ? SubStr( cDate, AtToken( cDate,, 3 ) )  // result: 06

      ? cTime                                  // result: 18:14:01
      ? SubStr( cTime, AtToken( cTime,, 2 ) )  // result: 14:01

      ? cFile                                  // result: Test.prg
      ? SubStr( cFile, AtToken( cFile ) )      // result: prg
   RETURN

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