Page 1 of 1

Findstring case insensitive bug(?)

Posted: Thu Apr 10, 2014 1:55 am
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:

Re: Findstring case insensitive bug(?)

Posted: Thu Apr 10, 2014 2:28 am
by Zach
You can get around it by running the string through LCase() or UCase() first, and testing for all lowercase or uppercase

Re: Findstring case insensitive bug(?)

Posted: Thu Apr 10, 2014 2:47 am
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)

Re: Findstring case insensitive bug(?)

Posted: Thu Apr 10, 2014 3:09 am
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. :)

Re: Findstring case insensitive bug(?)

Posted: Sat Apr 12, 2014 9:54 am
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!