Page 1 of 2
Make startposition optional in FindString()
Posted: Tue Dec 14, 2010 7:41 pm
by Demivec
I know this is a low priority request but a sensible one nonetheless.
FindString() is currently defined like this:
Code: Select all
Position = FindString(String$, StringToFind$, StartPosition)
Please change it to:
Code: Select all
Position = FindString(String$, StringToFind$ [, StartPosition]) ;StartPosition = 1 if not specified
It seems to me that FindString() is called with StartPosition = 1 at least half the time and this would simplify things a bit.
Re: Make startposition optional in FindString()
Posted: Tue Dec 14, 2010 8:48 pm
by blueznl
+1
Re: Make startposition optional in FindString()
Posted: Tue Dec 14, 2010 8:55 pm
by Little John
+1
In the old BASIC flavours that I know,
startposition of Instr() has always been optional.
As long as it's not implemented in PB, I use this:
Code: Select all
Macro Instr (_source_, _search_, _p_=1)
FindString(_source_, _search_, _p_)
EndMacro
Regards, Little John
Re: Make startposition optional in FindString()
Posted: Tue Dec 14, 2010 9:36 pm
by skywalk
Yes please.
Re: Make startposition optional in FindString()
Posted: Fri Dec 17, 2010 5:50 am
by Suirad
how hard is it to add ", 1" to the end of a command?
why dont you just wrap it in another procedure if its that much of a hastle?
Code: Select all
Procedure fFindstring(string.s,stringtofind.s,startposition=1)
ProcedureReturn FindString(string,stringtofind,startposition)
EndProcedure
Re: Make startposition optional in FindString()
Posted: Fri Dec 17, 2010 6:25 am
by KJ67
Suirad wrote:why dont you just wrap it in another procedure
Doing a wrapper with a procedure will give you extra overhead, Little John’s version with a macro is more efficient.
Re: Make startposition optional in FindString()
Posted: Fri Dec 17, 2010 9:02 am
by blueznl
Oh, it's a minor request, but it's true: most applications will use ,1 so why enforce millions of hits on thousands of keyboards, sore muscles and countless of kilojoules in energy wasted, all that energy used by the CPU to recompile because yet someone yet again has forgotten the ,1 and on top of it there's the electricity used to light up the room where the poor programmer is slaving his day away and neglecting his family for hour after hour (cumulative speaking, of course) because of the ,1 ?
You... you... you... energy waster!
Re: Make startposition optional in FindString()
Posted: Fri Dec 17, 2010 11:28 am
by Fred
Re: Make startposition optional in FindString()
Posted: Fri Dec 17, 2010 12:53 pm
by Kukulkan
+1
Re: Make startposition optional in FindString()
Posted: Fri Dec 17, 2010 1:27 pm
by shadow
+1
Re: Make startposition optional in FindString()
Posted: Fri Dec 17, 2010 4:58 pm
by Tenaja
Suirad wrote:how hard is it to add ", 1" to the end of a command?
why dont you just wrap it in another procedure if its that much of a hastle?
If you require the 1, then you break all existing code. That's a lot of work. Maybe not all for PB, but for all of its users.
BTW, count me as a +1 for this, too.
Re: Make startposition optional in FindString()
Posted: Thu Jan 06, 2011 10:16 pm
by AND51
—1
Why all the
+1's ... ? I thought you want to omit the ,1 so actually you all should write -1 in this thread, shouldn't you?
(
SCNR)
Re: Make startposition optional in FindString()
Posted: Fri Jan 07, 2011 3:38 am
by PB
Most apps don't use ,1 at all. Mine certainly don't! It depends on the app. The suggestion to drop it will break my sources just because you don't use it. Why is your code more important than mine? Use a simple macro and be done with it.
Re: Make startposition optional in FindString()
Posted: Fri Jan 07, 2011 4:37 am
by kenmo
+1
This wouldn't break any current code! It would simply remove a lot of ",1"s from future code.
Re: Make startposition optional in FindString()
Posted: Fri Jan 07, 2011 7:26 am
by Little John
PB wrote:Most apps don't use ,1 at all. Mine certainly don't! It depends on the app. The suggestion to drop it will break my sources just because you don't use it. Why is your code more important than mine? Use a simple macro and be done with it.
No!
Making
StartPosition optional in FindString() will
not break any existing code.