Champak Posted January 8, 2009 Share Posted January 8, 2009 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 More sharing options...
smashly Posted January 8, 2009 Share Posted January 8, 2009 (edited) 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 January 8, 2009 by smashly Link to comment Share on other sites More sharing options...
Champak Posted January 8, 2009 Author Share Posted January 8, 2009 (edited) 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 January 8, 2009 by Champak Link to comment Share on other sites More sharing options...
smashly Posted January 8, 2009 Share Posted January 8, 2009 (edited) 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 January 8, 2009 by smashly Link to comment Share on other sites More sharing options...
Champak Posted January 8, 2009 Author Share Posted January 8, 2009 Got you. Thanks. Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 8, 2009 Share Posted January 8, 2009 You could also send the Default keyword I think. 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