Thomymaster Posted November 22, 2014 Share Posted November 22, 2014 Hi I wrote some functions which, if the require parameters, always have default values Func _Example($sName,$sParam="",$bSilent=FALSE) ... EndFunc When i call the UDF and i only want the third parameter to be set (and not the second one, it goes to its default value) the following fails: _Example("Test",,TRUE) whereas this suceeds _Example("Test","Param1",TRUE) Is there a way in AutoIT to make the above work, so that if i completely omit a parameter, its taken from its default value in the function header? Cheers Thomy Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 22, 2014 Moderators Share Posted November 22, 2014 (edited) _Example("Test", "", True) Edit: Just send the default parameter data. Edited November 22, 2014 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
bestsmr Posted November 22, 2014 Share Posted November 22, 2014 Use "Default" Keyword _Example("Data",Default,True) it`s easier. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 22, 2014 Moderators Share Posted November 22, 2014 Use "Default" Keyword _Example("Data",Default,True) it`s easier. Be careful with that... It's not used how you think it is in udf's. Run this: _Example("name", Default, True) Func _Example($sName,$sParam="",$bSilent=FALSE) ConsoleWrite($sParam & @CRLF) EndFunc Which is why I said to do it how I had it ... Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Thomymaster Posted November 24, 2014 Author Share Posted November 24, 2014 OK thanks. And for what exactly is the "Default" keyword good? I mean i can always set the default parameters in the UDF header like: Func _test($iNum=1,$sString="Test") Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 24, 2014 Moderators Share Posted November 24, 2014 I wouldn't unless you're validating for the default keyword inside the function, and if it exists, changing the var to the default param string again, total waste of time unless you're making public functions IMO... test for yourself. _test(Default, Default) Func _test($iNum=1,$sString="Test") ConsoleWrite($sString & @CRLF) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Thomymaster Posted November 28, 2014 Author Share Posted November 28, 2014 OK, thanks a lot for the explanation Link to comment Share on other sites More sharing options...
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