[Implemted] FindString() default StartPosition = 1

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Leonhard
User
User
Posts: 55
Joined: Fri Jun 16, 2006 7:43 am

[Implemted] FindString() default StartPosition = 1

Post by Leonhard »

Why is the Parameter 'StartPosition' not default/optimal with 1?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: FindString(String$, StringToFind$, StartPosition = 1)

Post by PB »

It's an option so you can start searches anywhere in the string.
Is typing ",1" (only 2 characters) too much hassle for you? :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

yes but it's true that's better this way :

FindString(String$, StringToFind$[, StartPosition])


not very important...
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Leonhard
User
User
Posts: 55
Joined: Fri Jun 16, 2006 7:43 am

Post by Leonhard »

Flype wrote:yes but it's true that's better this way :

FindString(String$, StringToFind$[, StartPosition])


not very important...
yes, it is true!
But the default-Value is 1!
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Simple use a macro.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

maybe Leonhard does not use the third parameter...

but FindString reveals it's power only with using the third parameter...

Code: Select all

a$ = "the poop quick poop brown poop fox poop jumps poop over poop the poop lazy poop dog"
Pos = 0
Repeat
  Pos = FindString( a$, "poop", Pos+1 )
  Debug Pos
Until Pos = 0 
oh... and have a nice day.
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

I personally agree, it would be nice if this parameter is made optional (dare I hazard a guess that it's usually '1' for a high percentage of people's programs?). I was reminded about this idea when I saw that in the latest beta:
- Changed: last Mid() parameter optional
I think this suggestion is vaguely in the same vein as this change.
Post Reply