Jump to content

Calling a function with omitting some of its parameters, how?


Recommended Posts

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

  • Moderators

_Example("Test", "", True)

Edit:

Just send the default parameter data.

Edited 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

  • Moderators

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

  • Moderators

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

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
 Share

  • Recently Browsing   0 members

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