FindString Case BUG?

Just starting out? Need help? Post your questions and find answers here.
arma
User
User
Posts: 57
Joined: Sun Jul 24, 2016 11:54 pm

FindString Case BUG?

Post 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!
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: FindString Case BUG?

Post 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
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: FindString Case BUG?

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: FindString Case BUG?

Post 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:
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: FindString Case BUG?

Post by BarryG »

I knew what this "bug" was going to be even before I read the post. :)
Last edited by BarryG on Fri Jun 07, 2019 8:36 am, edited 1 time in total.
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: FindString Case BUG?

Post 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.
sorry for my bad english
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: FindString Case BUG?

Post 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.
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: FindString Case BUG?

Post by BarryG »

Josh wrote:Bad idea. Flags are always the last parameter.
Good point! Forgot I spoke. :oops:
Post Reply