Findstring case insensitive bug(?)

Just starting out? Need help? Post your questions and find answers here.
User avatar
happer66
User
User
Posts: 33
Joined: Tue Jan 12, 2010 12:10 pm
Location: Sweden

Findstring case insensitive bug(?)

Post by happer66 »

Maybe my brain isn't working as it should, but:
Changes in PB 5.10
- Added: #PB_String_NoCase mode parameter to FindString()
But the result doesn't match my expectations:

Code: Select all

Debug FindString("The quick brown fox jumps over the lazy dog","brown",#PB_String_CaseSensitive)
;Default mode. Returns 11 as it should.
Debug FindString("The quick brown fox jumps over the lazy dog","Brown",#PB_String_NoCase)
;Case insensitive so should return 11 (B=b). Returns 0
Tested under Windows 8.1 64-bit with PB 5.10(x86 compiler), 5.22 (unicode/ascii/x86/x64) same result.

Never used findstring alot in the past, and now I only need it for a small personal project so coding a horrible slow replacement procedure will work.
But I would like to know if I'm just doing it wrong or if it's a bug. Thanks.

OT: my sig should really be updated! :shock:
Image If your code isn't clean atleast make sure it's pure!
Zach
Addict
Addict
Posts: 1675
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Findstring case insensitive bug(?)

Post by Zach »

You can get around it by running the string through LCase() or UCase() first, and testing for all lowercase or uppercase
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Findstring case insensitive bug(?)

Post by Thunder93 »

Or include also the StartPosition parameter.. the way I think it was intended to be used as.

Code: Select all

Debug FindString("The quick brown fox jumps over the lazy dog","Brown", 1, #PB_String_NoCase)
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Findstring case insensitive bug(?)

Post by rsts »

Thunder93 wrote:Or include also the StartPosition parameter.. the way I think it was intended to be used as.

Code: Select all

Debug FindString("The quick brown fox jumps over the lazy dog","Brown", 1, #PB_String_NoCase)
As Thunder93 said, If you're including a Mode, you must include a start position, otherwise it takes the Mode parm as start position, in this case 1 with no mode= caseSensitive. :)
User avatar
happer66
User
User
Posts: 33
Joined: Tue Jan 12, 2010 12:10 pm
Location: Sweden

Re: Findstring case insensitive bug(?)

Post by happer66 »

Haha, never entered my mind that I missed a param. The statusbar clearly points it out in bold too when you're entering it. :mrgreen:
Thanks!
Image If your code isn't clean atleast make sure it's pure!
Post Reply