###Keyword###
Func...Return...EndFunc

###Description###
Defines a user-defined function that takes zero or more arguments and optionally returns a result.

###Syntax###
<b>Func</b> functioname ( [<b>Const</b>] [<b>ByRef</b>] $param1, ..., [<b>Const</b>] [<b>ByRef</b>] $paramN, $optionalpar1 = value, ...)
	...
	[<b>Return</b> [<i>value</i>]]
<b>EndFunc</b>


###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 <i>passed by value</i> 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, which could be a macro.  They are always the last in the definition.  If a parameter is given a default value, then all parameters after that one must also be given default values.  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.  

###Related###
<a href="Dim.htm">Dim/Global/Local</a>, <a href="include.htm">#include</a>, <a href="Dim.htm">Const</a>


###Example###
@@IncludeExample@@
