[NO BUG] FindString() fails with #PB_String_NoCase

Just starting out? Need help? Post your questions and find answers here.
User avatar
Blue
Addict
Addict
Posts: 868
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

[NO BUG] FindString() fails with #PB_String_NoCase

Post 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. :cry:

Code: Select all

Debug FindString("PureBasic", "Bas")  ; returns 5 as expected
Debug FindString("PureBasic", "bas", #PB_String_NoCase)  ; does NOT return 5 as expected
Last edited by Blue on Sun Apr 26, 2015 4:40 pm, edited 1 time in total.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
juror
Enthusiast
Enthusiast
Posts: 228
Joined: Mon Jul 09, 2007 4:47 pm
Location: Courthouse

Re: [PB 5.31] FindString() fails with #PB_String_NoCase

Post 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.
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: [PB 5.31] FindString() fails with #PB_String_NoCase

Post by TI-994A »

juror is right. The StartPosition parameter is missing:

Code: Select all

Debug FindString("PureBasic", "bas", 1, #PB_String_NoCase)   ;returns 5
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
Demivec
Addict
Addict
Posts: 4086
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: [PB 5.31] FindString() fails with #PB_String_NoCase

Post by Demivec »

I can confirm, incorrect use results in incorrect results :) :

Code: Select all

;Syntax
Position = FindString(String$, StringToFind$ [, StartPosition [, Mode]])
User avatar
Blue
Addict
Addict
Posts: 868
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: [PB 5.31] FindString() fails with #PB_String_NoCase

Post 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 ? :shock:

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 ?
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: [PB 5.31] FindString() fails with #PB_String_NoCase

Post by Thunder93 »

April must be the time of year people uses FindString(). Last April someone posted same thing :lol:
ʽʽ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
User avatar
Blue
Addict
Addict
Posts: 868
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: [PB 5.31] FindString() fails with #PB_String_NoCase

Post by Blue »

OK, now i see.
The way i wrote the second example made the constant the start position. :shock:

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.
Last edited by Blue on Sun Apr 26, 2015 4:45 pm, edited 2 times in total.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: [PB 5.31] FindString() fails with #PB_String_NoCase

Post 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. :wink:
ʽʽ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
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: [PB 5.31] FindString() fails with #PB_String_NoCase

Post by Thunder93 »

Oops I was to slow. :shock:
ʽʽ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
User avatar
Blue
Addict
Addict
Posts: 868
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: [PB 5.31] FindString() fails with #PB_String_NoCase

Post by Blue »

Thunder93 wrote:Oops I was to slow. :shock:
You should add "Get up earlier and be faster on the draw..." to that long quote about success you use. :D
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: [NO BUG] FindString() fails with #PB_String_NoCase

Post by Thunder93 »

heh :mrgreen:
ʽʽ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
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: [PB 5.31] FindString() fails with #PB_String_NoCase

Post by Dude »

Blue wrote:if you want to be really helpful, you need to elaborate a bit more in your explanations.
:lol: 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.
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: [NO BUG] FindString() fails with #PB_String_NoCase

Post by Thunder93 »

LOL! :lol:
ʽʽ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
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: [NO BUG] FindString() fails with #PB_String_NoCase

Post by Thunder93 »

Couldn't say that anyways. The code example was from the PB Manual. Therefore the PB Manual was of no help here. :lol:
ʽʽ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
Post Reply