Page 1 of 2

Optional parameter requests - any more?

Posted: Sat Sep 20, 2014 2:08 am
by kenmo
Another low-priority request :)

Over the years, many mandatory parameters have become optional, where it makes sense.

Here are some common functions with parameters that (I believe) could be made optional! (Usually default to 0 or "").

This would not be a functional change. Just a change for cleaner code. Feel free to suggest more!


EDIT: This is about just converting mandatory parameters to optional.
Not to be confused with this other active thread about leaving parameters in the middle of the list empty when calling, to use their defaults:
http://www.purebasic.fr/english/viewtop ... =3&t=60551


Code: Select all

Date
Currently the Date function either needs 0 parameters (returns the current timestamp) or 6 parameters (Year Month Day Hour Minute Second). It would be nice if you could use 3 parameters - often I specify a date by Year/Month/Day with the rest set to 0.

Code: Select all

ExamineDirectory
Pattern$ could default to ""

Code: Select all

ReadPreferenceDouble
ReadPreferenceFloat
ReadPreferenceInteger
ReadPreferenceLong
ReadPreferenceQuad
ReadPreferenceString
The DefaultValue parameters could default to 0 or ""

Code: Select all

CreateThread
The *Value parameter could default to #Null

Code: Select all

FontRequester
The Flags parameter could default to #Null. Maybe all the parameters (FontName and FontSize) could have defaults too, like ColorRequester?

Code: Select all

InputRequester
DefaultString could default to ""

Code: Select all

OpenFileRequester
SaveFileRequester
PatternPosition could default to 0

Re: Optional parameter requests - any more?

Posted: Sat Sep 20, 2014 8:47 am
by deesko
This one is a lot more useful than the other idea, and cleaner too. I second this.

Re: Optional parameter requests - any more?

Posted: Sat Sep 20, 2014 9:39 am
by Little John
+1

Re: Optional parameter requests - any more?

Posted: Sat Sep 20, 2014 9:49 am
by es_91
+50

Re: Optional parameter requests - any more?

Posted: Sat Sep 20, 2014 10:24 am
by c4s
To the listing above I would also add the other functions of the Date library:

Code: Select all

Day
DayOfWeek
DayOfYear
FormatDate
Hour
Minute
Month
Second
Year
Similar to Date(), not specifying the parameter would simply use the current date and time. (Already requested here.)

Re: Optional parameter requests - any more?

Posted: Wed Sep 24, 2014 2:19 am
by kenmo
I would like to add:

Code: Select all

ScintillaGadget
Callback could default to #Null

Code: Select all

StringGadget
Content$ could default to ""


I don't know how optional parameters are implemented by the PB libraries... but if it is a pain to convert all these, then it's not really necessary. :)

Re: Optional parameter requests - any more?

Posted: Sun Mar 15, 2015 4:22 am
by Blue
my suggestion :

Code: Select all

Debug
Default could be "".
So, "Debug" by itself would output a blank line,
not ring a bell, nor display an Alert telling you that you screwed up again !

At present I use

Code: Select all

Macro Debugg
  Debug ""
EndMacro
to achieve this purpose

Re: Optional parameter requests - any more?

Posted: Tue Apr 21, 2015 4:35 am
by kenmo
One more to add...

I think the Options parameter of SortList() and SortArray() could reasonably default to #PB_Sort_Ascending.

Re: Optional parameter requests - any more?

Posted: Tue Apr 21, 2015 9:39 am
by davido
+ 1

Re: Optional parameter requests - any more?

Posted: Wed Apr 22, 2015 8:28 am
by sancho2
MessageRequester()
There is no need for any parameters.

Re: Optional parameter requests - any more?

Posted: Wed Apr 22, 2015 8:57 am
by bbanelli
sancho2 wrote:MessageRequester()
There is no need for any parameters.
That would be, like, the most useful message ever. :D

Image

Re: Optional parameter requests - any more?

Posted: Wed Apr 22, 2015 3:24 pm
by Thunder93
What I like about it is it's very comprehensiveness, and so simplistic. Like trusting the words of car dealerships and wanting you to just sign on the dotted line. I don't need to know what it's about, just click OK. :mrgreen:

bbanelli wrote:
sancho2 wrote:MessageRequester()
There is no need for any parameters.
That would be, like, the most useful message ever. :D

Image

Re: Optional parameter requests - any more?

Posted: Wed Apr 22, 2015 11:15 pm
by Dude
A blank MessageRequester is actually a good way to pause your app during debugging (outside of the IDE).

Re: Optional parameter requests - any more?

Posted: Wed Apr 22, 2015 11:25 pm
by Little John
Thunder93 wrote:What I like about it is it's very comprehensiveness, and so simplistic. Like trusting the words of car dealerships and wanting you to just sign on the dotted line. I don't need to know what it's about, just click OK. :mrgreen:
Image

Re: Optional parameter requests - any more?

Posted: Thu Apr 23, 2015 4:59 am
by sancho2
bbanelli wrote:That would be, like, the most useful message ever. :D
LOL,

I use a blank msgbox often during debugging as was mentioned.
I would also link this request with the "skip-optional parameters request". For example:

Code: Select all

MessageRequester(,"hello")
As well as the "shorten the name of the MessageRequester function request" (to maybe MsgBox?). But I'm drifting off topic now.