hb_tokenCount error

14 views
Skip to first unread message

Daniel Garcia-Gil

unread,
Aug 27, 2010, 7:30:30 AM8/27/10
to Harbour Developers
Hello

the function hb_tokenCount return incorrect value

local ctext := "A;B;C:D;E;F"

? hb_tokenCount( cText, ":" ) // -> return 2 should be 1
? hb_tokenCount( ctext, ";" ) // -> return 5 should be 4

hbtoken.c
line 66 should be
HB_SIZE ul = 0, nTokens = 0;

or is right this behavior

Mindaugas Kavaliauskas

unread,
Aug 27, 2010, 7:41:28 AM8/27/10
to harbou...@googlegroups.com
Hi,


On 2010.08.27 14:30, Daniel Garcia-Gil wrote:
> the function hb_tokenCount return incorrect value
>
> local ctext := "A;B;C:D;E;F"
>
> ? hb_tokenCount( cText, ":" ) // -> return 2 should be 1

I guess "A;B;C" and "D;E;F" are two.


Regards,
Mindaugas

druzus

unread,
Aug 27, 2010, 7:46:14 AM8/27/10
to Harbour Developers
On 27 Sie, 13:30, Daniel Garcia-Gil <danielgarcia...@gmail.com> wrote:

Hi,

> the function hb_tokenCount return incorrect value
>    local ctext := "A;B;C:D;E;F"
>    ? hb_tokenCount( cText, ":" ) // ->  return 2 should be 1
>    ? hb_tokenCount( ctext, ";" ) // ->  return 5 should be 4
> or is right this behavior

It's expected behavior. The second parameter in hb_tokenCount()
function is token delimiter not token itself.
This code should help you understand what hb_token*()
functions do:

proc main()
local ctext := "A;B;C:D;E;F"
? hb_tokenCount( cText, ":" ), len( hb_aTokens( cText, ":" ) )
? hb_tokenCount( ctext, ";" ), len( hb_aTokens( cText, ";" ) )
? hb_valToExp( hb_aTokens( cText, ":" ) )
? hb_valToExp( hb_aTokens( cText, ";" ) )
return

best regards,
Przemek

Daniel Garcia-Gil

unread,
Aug 27, 2010, 7:53:30 AM8/27/10
to Harbour Developers
ops sorry my mistake

we need count tokens... no count delimiters

On Aug 27, 7:30 am, Daniel Garcia-Gil <danielgarcia...@gmail.com>
wrote:

Daniel Garcia-Gil

unread,
Aug 27, 2010, 7:55:58 AM8/27/10
to Harbour Developers
Thanks!!!

On Aug 27, 7:53 am, Daniel Garcia-Gil <danielgarcia...@gmail.com>
Reply all
Reply to author
Forward
0 new messages