Guest Posted February 19, 2017 Posted February 19, 2017 (edited) This Test(Default) Func Test($var = 10) ConsoleWrite($var & @CRLF) EndFunc 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 February 19, 2017 by Guest
Moderators Melba23 Posted February 19, 2017 Moderators Posted February 19, 2017 gil900, 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. M23 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: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
spudw2k Posted February 20, 2017 Posted February 20, 2017 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. " Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now