Jump to content

I can't get my function para. working right


Recommended Posts

If I'm calling the function like:

Function ( "App Title", "", 33333, "", "", "", "", 2 )

If my function is set up as:

Function ( $ETitle, $EText, $EID, $EButton = "Left", $EClicks = "1", $EX = "", $EY = "", $EOptionMatch = 1 )

Shouldn't the "$EButton" pass "Left", and "$EClicks" pass "1" to my function? Welll it isn't...it's just passing "empty values", what am I doing it wrong?

Link to comment
Share on other sites

Hi,

for the default param values would work if you don't pass any param to the function..

eg:

Function ("App Title", "", 33333)

Then all the params after the $EID will use the default params as specified in the function.

But by passing a param a value (even a null or empty value) then the function will use the param passed.

Cheers

Edited by smashly
Link to comment
Share on other sites

Sorry, don't understand.

EDIT: OK, I get what you are saying. So then are you also saying things with default parameters towards the end of the parameter set should be moved towards the "front of the line"? If so, I think this should be "fixed".

Edited by Champak
Link to comment
Share on other sites

No, I probably could have explained it better..

eg:

Calling the function like

Function ("App Title", "", 33333)

Then all the params after the $EID will use the default params as specified in the function.

Required parameters should be at the beginning of the function (no default value).

Optional parameters should be at the end of the function (default value supplied).

If you call the function and you need to set an optional param value then you will need to set all the values for all prior optional params before the param your setting the value to.

Ways to make it so a user can use an empty value as a param and still have the function use a default would be to make the function check the params that are passed to it and if the param is empty then set a default value from within the function.

Edited by smashly
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...