FUNCTION
Syntax: #FU name {script} classname
This command is used to create a user-defined function. name is the name of the function, and script is the script to execute. A #RETURN command is needed somewhere in the script to return the value of the function. If no argument list is given, then you can access the arguments passed to the function using the %1..%99 variables.
NOTE: In zMUD and in CMUD versions prior to 2.0, this command performed the action of the current #VARFUNC command and created an inline function rather than a normal script.
FUNCTION Examples
#FUNCTION MySum($a,$b) {#RETURN ($a+$b)}
Creates a function that returns the sum of it's given two arguments. For example, @MySum(1,3) would return the value of 4.
#FUNCTION MySum {$val=0;#LOOP %numparam {$val = $val + %param(%i)};#RETURN $val}
Creates a function that returns the sum of it's arguments and handles any number of arguments (up to 99). For example, @MySum(1,3,4) would return the value of 8. |