rabbitkillrun Posted December 10, 2008 Share Posted December 10, 2008 How can i make parameters in my functions from being mandatory...? Like actual autoit functions have ones in []'s that are optional... thanks rkr... Link to comment Share on other sites More sharing options...
Developers Jos Posted December 10, 2008 Developers Share Posted December 10, 2008 What did the helpfile tell you ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
rabbitkillrun Posted December 10, 2008 Author Share Posted December 10, 2008 haven't got the help file... i copied autoit onto my pendrive so i could use it on my other comp if needed, but i guess i missed a file or two... :S although i guess it's on the website, right...? *facepalm* Link to comment Share on other sites More sharing options...
Developers Jos Posted December 10, 2008 Developers Share Posted December 10, 2008 Keyword Reference Func...Return...EndFunc -------------------------------------------------------------------------------- Defines a user-defined function that takes zero or more arguments and optionally returns a result. Func functioname ( [Const] [byRef] $param1, ..., [Const] [byRef] $paramN, $optionalpar1 = value, ...) ... [Return [value]] EndFunc Parameters The parameters are set by you. You later call the function like any other built-in function. Remarks The Const keyword is optional and indicates that the value of the parameter will not change during the execution of the function. A variable declared Const can only be passed to a function using a Const parameter. The ByRef keyword is optional and means: (1) the parameter must a variable, and (2) the original variable is linked to the parameter, so that any changes to the parameter inside the function, would affect the original variable as well. By default, a parameter is passed by value which means that a copy of the parameter's value, is manipulated by the function. The order of the ByRef and Const keywords is not important, so long as they are in front of the variable they modify. Arrays can be passed to functions (and returned from them) by simply using the array name without any brackets. Arrays should be passed to user-defined functions using the ByRef keyword to avoid copying all the data in the array. Optional parameters are defined by assigning a default value to them. The value may be a global variable, macro or literal value. Optional parameters always appear last in the function definition. All parameters added after the first optional parameter must also be optional. Inside the function, the number of parameters given when the function was called can be retrieved with the @NUMPARAMS macro. Use the Return keyword to exit the function. Unlike built-in functions, user-defined functions return 0 unless another return value is specified. Note that function declarations cannot appear inside other function declarations. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
rabbitkillrun Posted December 10, 2008 Author Share Posted December 10, 2008 (edited) thanks a lot... edit: ok, wait... i'm stuck... so i have a function like this...: Func _myFunc($param1,$param2,$param3,$param4) and only the first two parameters are needed for teh function to work... so i tried declaring $param3 and $param4 as global variables, but it still says "Incorrect number of parameters in function call"... help...? Edited December 10, 2008 by rabbitkillrun Link to comment Share on other sites More sharing options...
Pain Posted December 10, 2008 Share Posted December 10, 2008 Optional parameters always appear last in the function definition. All parameters added after the first optional parameter must also be optional. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 10, 2008 Moderators Share Posted December 10, 2008 Func _myfunc($not_optional_1, $not_optional_2, $optional_1 = "some value or blank string", $optional_2 = "some value or blank string") 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...
rabbitkillrun Posted December 12, 2008 Author Share Posted December 12, 2008 Optional parameters always appear last in the function definition. All parameters added after the first optional parameter must also be optional.Yeahh, i got that bit... and that seems like common sense to me...Func _myfunc($not_optional_1, $not_optional_2, $optional_1 = "some value or blank string", $optional_2 = "some value or blank string")thank you... perfect... Link to comment Share on other sites More sharing options...
Valuater Posted December 12, 2008 Share Posted December 12, 2008 (edited) NVM... 8) Edited December 12, 2008 by Valuater 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