PureBasic Forum
http://forums.purebasic.com/english/

FindString Case BUG?
http://forums.purebasic.com/english/viewtopic.php?f=13&t=72969
Page 1 of 1

Author:  arma [ Thu Jun 06, 2019 1:50 pm ]
Post subject:  FindString Case BUG?

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!

Author:  Shardik [ Thu Jun 06, 2019 2:35 pm ]
Post subject:  Re: FindString Case BUG?

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:
a$="TEST.Server":m$="server"
Debug FindString(a$,m$, 1, #PB_String_CaseSensitive) ; 0
Debug FindString(a$,m$, 1, #PB_String_NoCase)        ; 6

Author:  NicTheQuick [ Thu Jun 06, 2019 3:30 pm ]
Post subject:  Re: FindString Case BUG?

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.

Author:  Little John [ Thu Jun 06, 2019 8:27 pm ]
Post subject:  Re: FindString Case BUG?

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:

Author:  BarryG [ Fri Jun 07, 2019 3:01 am ]
Post subject:  Re: FindString Case BUG?

I knew what this "bug" was going to be even before I read the post. :)

Author:  Josh [ Fri Jun 07, 2019 5:34 am ]
Post subject:  Re: FindString Case BUG?

BarryG wrote:
Maybe the two parameters could be swapped (flag first, optional start position second)

Bad idea. Flags are always the last parameter.

Author:  Little John [ Fri Jun 07, 2019 5:51 am ]
Post subject:  Re: FindString Case BUG?

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.

Author:  BarryG [ Fri Jun 07, 2019 8:36 am ]
Post subject:  Re: FindString Case BUG?

Josh wrote:
Bad idea. Flags are always the last parameter.

Good point! Forgot I spoke. :oops:

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/