Optional parameter requests - any more?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Optional parameter requests - any more?

Post 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
Last edited by kenmo on Sat Sep 20, 2014 2:37 pm, edited 1 time in total.
deesko
User
User
Posts: 39
Joined: Fri Sep 21, 2012 11:40 pm
Location: Portugal

Re: Optional parameter requests - any more?

Post by deesko »

This one is a lot more useful than the other idea, and cleaner too. I second this.
Little John
Addict
Addict
Posts: 4778
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Optional parameter requests - any more?

Post by Little John »

+1
es_91
Enthusiast
Enthusiast
Posts: 298
Joined: Thu Jan 27, 2011 12:00 pm
Location: DE

Re: Optional parameter requests - any more?

Post by es_91 »

+50
:mrgreen:
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Optional parameter requests - any more?

Post 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.)
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Re: Optional parameter requests - any more?

Post 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. :)
User avatar
Blue
Addict
Addict
Posts: 964
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Optional parameter requests - any more?

Post 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
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Re: Optional parameter requests - any more?

Post by kenmo »

One more to add...

I think the Options parameter of SortList() and SortArray() could reasonably default to #PB_Sort_Ascending.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Optional parameter requests - any more?

Post by davido »

+ 1
DE AA EB
sancho2
User
User
Posts: 44
Joined: Wed Apr 15, 2015 5:14 am

Re: Optional parameter requests - any more?

Post by sancho2 »

MessageRequester()
There is no need for any parameters.
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: Optional parameter requests - any more?

Post by bbanelli »

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

Image
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Optional parameter requests - any more?

Post 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
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Optional parameter requests - any more?

Post by Dude »

A blank MessageRequester is actually a good way to pause your app during debugging (outside of the IDE).
Little John
Addict
Addict
Posts: 4778
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Optional parameter requests - any more?

Post 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
sancho2
User
User
Posts: 44
Joined: Wed Apr 15, 2015 5:14 am

Re: Optional parameter requests - any more?

Post 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.
Post Reply