# ATTOKEN()

Position of a token in a string

Syntax

  ATTOKEN (<cString>, [<cTokenizer>],
  [<nTokenCount>], [<nSkipWidth>]) -> nPosition

Arguments

  <cString> is the processed string [<cTokenizer>] is a list of characters separating the tokens in <cString> Default: chr(0)+chr(9)+chr(10)+chr(13)+chr(26)+ chr(32)+chr(32)+chr(138)+chr(141)+ ",.;:!\?/\\<>()#&%+-*" [<nTokenCount>] specifies the count of the token whose position should be calculated Default: last token [<nSkipWidth>] specifies the maximum number of successive tokenizing characters that are combined as ONE token stop, e.g. specifying 1 can yield to empty tokens Default: 0, any number of successive tokenizing characters are combined as ONE token stop

Returns

  <nPosition> The start position of the specified token or 0 if such a token does not exist in <cString>.

Description

  The ATTOKEN() function calculates the start position of tne <nTokenCount>th token in <cString>. By setting the new <nSkipWidth> parameter to a value different than 0, you can specify how many tokenizing characters are combined at most to one token stop. Be aware that this can result to empty tokens there the start position is not defined clearly. Then, ATTOKEN() returns the position there the token WOULD start if its length is larger than 0. To check for empty tokens, simply look if the character at the returned position is within the tokenizer list.

Examples

          attoken ("Hello, World!")  --> 8  // empty strings after tokenizer
                                            // are not a token !
    Tests
          attoken ("Hello, World!") == 8
          attoken ("Hello, World!",,2) == 8
          attoken ("Hello, World!",,2,1) == 7
          attoken ("Hello, World!"," ",2,1) == 8

Status

  Ready

Compliance

  ATTOKEN() is compatible with CT3's ATTOKEN, but has an additional 4th parameter to let you specify a skip width equal to that in the TOKEN() function.

Platforms

  All

Files

  Source is token1.c, library is libct.

See Also

- TOKEN()
- NUMTOKEN()
- TOKENLOWER()
- TOKENUPPER()
- TOKENSEP()