Is there a function that can count the number of times the same string shows up in a variable
for example cVariable := "user1/temp/temp"
I Need to count how many times temp shows up in cVariable.
Thanks for any help.
James Bott wrote:Uwe,
I see the -1. So it really returns one more than the token count? Is this a bug?
Maybe we should create a better function:
function TokenCount( cString, cToken )
return ( hb_tokenCount( cString, cToken) -1 )
James
Occurs( <cSubStr>, <cString> ) --> nCount
NumAt( <cSubStr>, <cString> ) --> nCount // ct.lib
msgalert( hb_tokenCount( "user1/temp/temp", "temp" ) -1 ) // Result 2
If we are looking for the number of occurances of "temp" shouldn't hb_tokenCount() return 2? Then the above should return 1, correct?
The Occurs() function seems to be the better and less confusing choice.
The tokens separated by "temp" are "user1/", "/" and "",
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 95 guests