Page 1 of 1

Inaccuracy in the description of the function DC_TokenNum

Posted: Sat Jul 12, 2014 10:10 pm
by Eugene Lutsenko
Yet I could not get to function DC_TokenNum( Fv ) worked with all separators provided by default. Have to write it in the form: DC_TokenNum( Fv ," " ), which is undesirable because there are other delimiters.

Can be used:
cDelims = " Š,.;:!?/()#&%+-*"+CHR(0)+CHR(9)+CHR(10)+CHR(13)+CHR(26)
DC_TokenNum( Fv , cDelims )

What is the difference function DC_TokenNum and DC_Token of unparalleled NumToken and Token?

The function is called DC_TokeNum (), and in the Examples herein words DK_NUMTOKEN() that is not in the dll:


Syntax:

DC_TokenNum ( <cString>, ;
[<cDelims>] ) -> nTokens


Arguments:

<cString> is a character string containing tokens.

<cDelims> is a character string containing the delimeter(s)
to use between tokens. If no parameter is passed then the
following default set of delimeters will be used:

<SPACE>
Š,.;:!?/()#&%+-*
<CHR(0)>
<CHR(9)>
<CHR(10)>
<CHR(13)>
<CHR(26)>

Returns:

A numeric value.


Description:

DC_TOKENNUM() is used to determine the number of tokens
that exist in a character string.

Tokens are sub-strings within a string that are separated
by common delimiters.


Examples:

cString := 'This is a test'
? DC_Token( cString,,2 )
is
? DC_NUMTOKEN( cString )
4

cString := 'AB|CD|EF|GHI|JKLM|NOP|QR|STUVW|XYZ'
? DC_Token( cString,'|',5 )
JKLM
? DC_NUMTOKEN( cString )
9


Source/Library:

_DCTOKEN.PRG/.OBJ, DCLIPX.LIB

See Also:

dc_token(), dc_tokenarray()

Re: Inaccuracy in the description of the function DC_TokenNu

Posted: Wed Jul 16, 2014 10:20 am
by rdonnay
Eugene -

I may not have kept up with DC_TokenNum() over the years because I never use it.

I always call DC_TokenArray() which returns an array of tokens.
This is a workaround for you.

nTokens := Len(DC_TokenArray(cString))

Roger

Re: Inaccuracy in the description of the function DC_TokenNu

Posted: Wed Jul 16, 2014 12:22 pm
by Eugene Lutsenko
Similarly, as I myself did not think :)