Page 1 of 1

FindString Case BUG?

Posted: Thu Jun 06, 2019 1:50 pm
by arma
Hello Everybody,
I am confused if this is BUG or NOT...
Is this code works normally? Or how "#PB_String_NoCase" works?
I did think #PB_String_NoCase means it finds the same string (dont care capital or not as case) But it doesnt do that...
If this is BUG Please fix this on the future release! If this is NOT BUG then what does this do?

My Sample Code:
a$="TEST.Server":m$="server"
Debug FindString(a$,m$,#PB_String_CaseSensitive)
Debug FindString(a$,m$,#PB_String_NoCase)

Thanks A LOT!

Re: FindString Case BUG?

Posted: Thu Jun 06, 2019 2:35 pm
by Shardik
Many users have already complained about the seemingly FindString() error. But - like you - they have simply forgotten the 3rd parameter:
PureBasic reference for FindString() wrote:Position = FindString(String$, StringToFind$ [, StartPosition [, Mode]])
After adding the StartPosition 1 your code works correctly:

Code: Select all

a$="TEST.Server":m$="server"
Debug FindString(a$,m$, 1, #PB_String_CaseSensitive) ; 0
Debug FindString(a$,m$, 1, #PB_String_NoCase)        ; 6

Re: FindString Case BUG?

Posted: Thu Jun 06, 2019 3:30 pm
by NicTheQuick
Please don't ask questions about "bug or not" in the bug forum. Always ask in a coding forum first to make sure you did not have an error in your code.

Re: FindString Case BUG?

Posted: Thu Jun 06, 2019 8:27 pm
by Little John
And maybe people could also read the related documentation before posting a "bug report"?
Yes I know, that's a strange idea, but I wanted to mention it anyway. :twisted:

Re: FindString Case BUG?

Posted: Fri Jun 07, 2019 3:01 am
by BarryG
I knew what this "bug" was going to be even before I read the post. :)

Re: FindString Case BUG?

Posted: Fri Jun 07, 2019 5:34 am
by Josh
BarryG wrote:Maybe the two parameters could be swapped (flag first, optional start position second)
Bad idea. Flags are always the last parameter.

Re: FindString Case BUG?

Posted: Fri Jun 07, 2019 5:51 am
by Little John
BarryG wrote:Maybe the two parameters could be swapped (flag first, optional start position second) to avoid this?
That would break a lot of existing code.
Such changes in a programming language should be made only for important reasons.
The fact that some people want to use a PB function without having read its documentation is NO reason for changing it.

Re: FindString Case BUG?

Posted: Fri Jun 07, 2019 8:36 am
by BarryG
Josh wrote:Bad idea. Flags are always the last parameter.
Good point! Forgot I spoke. :oops: