CT_TOKENAT

 TOKENAT()
 Determines the most recent TOKENNEXT() position within a string
------------------------------------------------------------------------------
 Syntax

     TOKENAT(<lLastTokenPos>) --> nPosition

 Argument

     <lLastTokenPos>  When designated as .T., this parameter returns the
     delimiter position after the last token found.

 Returns

     TOKENAT() returns the beginning position of the token most recently
     returned using TOKENNEXT().  If TOKENINIT() and TOKENNEXT() have not
     been called prior to calling TOKENAT(), the function returns 0.

 Description

     TOKENAT() returns the starting position of the token most recently
     extracted by TOKENNEXT().  If TOKENAT() is used in conjunction with
     SUBSTR(), the delimiters before the token in an incremental tokenizer
     are available.  To determine the delimiter position before the last
     token, set TOKENAT() to -1.  To determine the delimiter position after
     the last token, set TOKENAT to .T..

     Please notice that the character string initialized by TOKENINIT() no
     longer contains the original delimiters.  If you need the original
     delimiters, you should make a copy before you call TOKENINIT().

 Example

     This example shows five tokens and their starting positions:

     cString  :=  "This is a search, 234"
     cCopy    :=  String
     TOKENINIT(@cString)
     ? TOKENNEXT(), TOKENAT()                  // "This", 1
     ? TOKENNEXT(), TOKENAT()                  // "is", 6
     ? TOKENNEXT(), TOKENAT()                  // "a", 9
     ? TOKENNEXT(), TOKENAT()                  // "search", 11
     ? TOKENNEXT(), TOKENAT()                  // "234", 18
     ? SUBSTR(cCOPY, TOKENAT() -1, 1           // Delimiter : ","

See Also: TOKENINIT() TOKENNEXT()



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.