Jump to content

What is the point of the key "Default" if it have 0 effect?


Recommended Posts




Func Test($var = 10)
    ConsoleWrite($var & @CRLF)


Will print "Default" and not 10.

Due to this, There is no any logic why make it look "special". Unless it will realy actually prints 10 without any additional code.

Otherwise it's just like any regular string.

Why you did not make it so it will naturally get the Default value?

Edited by Guest
Link to comment
Share on other sites

  • Moderators


Of course it prints "10" - there is a big difference between the Default keyword as a parameter and a default parameter in a function definition.

The Default keyword as a parameter tells the function that the user wishes the parameter to use whatever the function defines internally as a default value, which must be set programmatically within the function. A default parameter in a function definition tells the function what to use if that parameter is omitted when the function is called. So in the example you give, the parameter is set to Default keyword - and that is what the function receives to do with as it sees fit. If you omit the parameter when calling the function it will use the default value for that parameter which is defined as 10.

To me the difference between these two behaviours is so obvious that I am struggling to see how it can possibly be unclear to others.


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Link to comment
Share on other sites

Agreed.  As per the help file,
" When used in parameter passing, the behavior is specified in the corresponding AutoIt function documentation.
For UDF's, it is the scripter's responsibility to check if the parameter has been set to Default and to perform the desired behavior in this situation.
If used, the passed parameter will be set to the Default keyword and not to an optional parameter value, if defined. "

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...