Jump to content
Sign in to follow this  
Champak

I can't get my function para. working right

Recommended Posts

Champak

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?

Share this post


Link to post
Share on other sites
smashly

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

Share this post


Link to post
Share on other sites
Champak

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

Share this post


Link to post
Share on other sites
smashly

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

Share this post


Link to post
Share on other sites
Richard Robertson

You could also send the Default keyword I think.

Share this post


Link to post
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
Sign in to follow this  

×