Page 1 of 1
FindString optional start parameter
Posted: Wed Aug 06, 2008 10:30 pm
by kenmo
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.
Posted: Thu Aug 07, 2008 1:00 am
by Little John
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
Posted: Thu Aug 07, 2008 1:35 am
by PB
With Mid() the parameter became optional because it reduced a lot of typing
and the need for yet another string command (Len). For example...
Code: Select all
Mid(windowsfolder$,10,Len(windowsfolder$))
...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:
Code: Select all
Macro InStr(main,part) : FindString(main,part,1) : EndMacro
Debug InStr("12345","3") ; Returns 3.
Posted: Thu Aug 07, 2008 1:54 am
by Little John
Yes ... And probably Fred or Freak will need about 10 minutes or so to make the suggested change.
Regards, Little John
Posted: Thu Aug 07, 2008 2:09 am
by PB
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.
Posted: Thu Aug 07, 2008 2:28 am
by Little John
PB wrote:Plus it breaks all existing apps that use FindString.
No, not at all! It will not break a single line of code, since
would still be legal code, of course. The suggestion is that the coder would be
allowed to omit the start position, not that s/he would be
forced to do so. The latter wouldn't make sense anyway.
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
Posted: Thu Aug 07, 2008 2:42 am
by PB
Sorry, I forgot it would be optional.

Posted: Thu Aug 07, 2008 5:54 am
by kenmo
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...
Code: Select all
Mid(windowsfolder$,10,Len(windowsfolder$))
...became so much simpler and quicker to type:
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.
But I still like the optional FindString() idea.

Posted: Thu Aug 07, 2008 8:30 am
by akj
I second this as I am frequently forgetting to add the ,1 to the end of FindString() and I almost NEVER need to use anything other than ,1 .
Also, I would like the final length parameter to default to 1 for Left() and Right().
Posted: Thu Aug 07, 2008 8:19 pm
by blueznl
+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!

Posted: Thu Aug 07, 2008 10:59 pm
by kenmo
akj wrote:Also, I would like the final length parameter to default to 1 for Left() and Right().
Ah yes, +1 for that as well!