FindString optional start parameter
FindString optional start parameter
A very small suggestion here: Now that the length parameter of Mid() is optional and defaults to 1, doesn't it make sense that the start position parameter of FindString() should as well? No functionality change at all, just a little less clutter.
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
I support this suggestion/wish. This is possible with Instr() in all other Basic flavours that I know. Having this option in PB would make converting code like this
from other Basic flavours easier.
Regards, Little John
Code: Select all
i = Instr(Main$, Part$)
Regards, Little John
With Mid() the parameter became optional because it reduced a lot of typing
and the need for yet another string command (Len). For example...
...became so much simpler and quicker to type:
But with FindString(), all you need to type are 2 little chars at the end: ,1
And Macros can always give you a new version of the command that makes
porting from other Basics easier:
and the need for yet another string command (Len). For example...
Code: Select all
Mid(windowsfolder$,10,Len(windowsfolder$))
Code: Select all
Mid(windowsfolder$,10)
And Macros can always give you a new version of the command that makes
porting from other Basics easier:
Code: Select all
Macro InStr(main,part) : FindString(main,part,1) : EndMacro
Debug InStr("12345","3") ; Returns 3.
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Well, they have said in the past that it requires a recompile of the required
lib and doc changes in three languages... and they are not keen to do that
just because someone doesn't want to type: ,1
Plus it breaks all existing apps that use FindString.
Still think they'll do it? I'd be very surprised.
lib and doc changes in three languages... and they are not keen to do that
just because someone doesn't want to type: ,1
Plus it breaks all existing apps that use FindString.
Still think they'll do it? I'd be very surprised.
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
No, not at all! It will not break a single line of code, sincePB wrote:Plus it breaks all existing apps that use FindString.
Code: Select all
FindString(Main$, Part$, 1)
It is paradox that we can use optional parameters in self-written procedures, but not in a built-in function such as FindString().
Regards, Little John
Oh, you're right! I thought if you left out that parameter it would read 1 character, not until the end of the string. Good to know.PB wrote:With Mid() the parameter became optional because it reduced a lot of typing
and the need for yet another string command (Len). For example...
...became so much simpler and quicker to type:Code: Select all
Mid(windowsfolder$,10,Len(windowsfolder$))
Code: Select all
Mid(windowsfolder$,10)
But I still like the optional FindString() idea.

+1 here as well, the third parameter does always force me to do another compile... so actually, the pb devs would need 10 minutes, yet they would save humanity hours and days and weeks and months and perhaps years!


( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )