Page 1 of 1
[NO BUG] FindString() fails with #PB_String_NoCase
Posted: Sun Apr 26, 2015 3:36 pm
by Blue
• applies to PB 5.31 x86 and x64
• tested under Windows 8.1 x64
FindString() with the
#PB_String_NoCase flag is supposed to be case indifferent.
But it does not work.
Code: Select all
Debug FindString("PureBasic", "Bas") ; returns 5 as expected
Debug FindString("PureBasic", "bas", #PB_String_NoCase) ; does NOT return 5 as expected
Re: [PB 5.31] FindString() fails with #PB_String_NoCase
Posted: Sun Apr 26, 2015 4:11 pm
by juror
Isn't there another parm that's required when you use the nocase flag, thus rendering this incorrect for nocase?
You're using a startposition of 1. No bug.
Re: [PB 5.31] FindString() fails with #PB_String_NoCase
Posted: Sun Apr 26, 2015 4:16 pm
by TI-994A
juror is right. The
StartPosition parameter is missing:
Code: Select all
Debug FindString("PureBasic", "bas", 1, #PB_String_NoCase) ;returns 5
Re: [PB 5.31] FindString() fails with #PB_String_NoCase
Posted: Sun Apr 26, 2015 4:18 pm
by Demivec
I can confirm, incorrect use results in incorrect results

:
Code: Select all
;Syntax
Position = FindString(String$, StringToFind$ [, StartPosition [, Mode]])
Re: [PB 5.31] FindString() fails with #PB_String_NoCase
Posted: Sun Apr 26, 2015 4:24 pm
by Blue
juror wrote:Isn't there another parm that's required when you use the nocase flag, thus rendering this incorrect for nocase?
You're using a startposition of 1. No bug.
How do you reach this conclusion ?
I'm just relying on the information provided by the Help File.
Example #1 is straight from the Help file, using the default mode.
Example #2 basically the same, using the other mode.
Yes, the examples start searching from position 1.
But isn't that simply the most frequent way the Search function is used ?
Could you elaborate a bit ?
Re: [PB 5.31] FindString() fails with #PB_String_NoCase
Posted: Sun Apr 26, 2015 4:25 pm
by Thunder93
April must be the time of year people uses FindString(). Last April someone posted same thing

Re: [PB 5.31] FindString() fails with #PB_String_NoCase
Posted: Sun Apr 26, 2015 4:29 pm
by Blue
OK, now i see.
The way i wrote the second example made the constant the start position.
All right, thank you guys.
But, sometimes, if you want to be really helpful, you need to elaborate a bit more in your explanations.
In short, when using the '#PB_String_NoCase' flag, never forget to specify the starting position !
SUGGESTION : Change the '
#PB_String_NoCase' constant to
-1 (or some other invalid value) instead of 1, and have the compiler generate an error to force distracted programmers to take notice.
Re: [PB 5.31] FindString() fails with #PB_String_NoCase
Posted: Sun Apr 26, 2015 4:32 pm
by Thunder93
If you don't specify the previous optional parameter, then how can the code know for sure you referring to the secondary parameter? Right now using just #PB_String_CaseSensitive Mode, saying to use 0 for start position.

Re: [PB 5.31] FindString() fails with #PB_String_NoCase
Posted: Sun Apr 26, 2015 4:33 pm
by Thunder93
Oops I was to slow.

Re: [PB 5.31] FindString() fails with #PB_String_NoCase
Posted: Sun Apr 26, 2015 5:44 pm
by Blue
Thunder93 wrote:Oops I was to slow.

You should add "
Get up earlier and be faster on the draw..." to that long quote about success you use.

Re: [NO BUG] FindString() fails with #PB_String_NoCase
Posted: Sun Apr 26, 2015 5:52 pm
by Thunder93
heh

Re: [PB 5.31] FindString() fails with #PB_String_NoCase
Posted: Sun Apr 26, 2015 11:06 pm
by Dude
Blue wrote:if you want to be really helpful, you need to elaborate a bit more in your explanations.

Those answers
were helpful. A couple of years ago, you would've just been told: RTFM!
You don't really see that much anymore, for some reason. Maybe the online world is maturing.
Re: [NO BUG] FindString() fails with #PB_String_NoCase
Posted: Sun Apr 26, 2015 11:10 pm
by Thunder93
LOL!

Re: [NO BUG] FindString() fails with #PB_String_NoCase
Posted: Sun Apr 26, 2015 11:13 pm
by Thunder93
Couldn't say that anyways. The code example was from the PB Manual. Therefore the PB Manual was of no help here.
