Was this helpful?
Variables Definitions
Local Variables belong to a function. These variables are not related to variables outside the scope of the function even if there are other variables with the same name.
Global Variables can be accessed from anywhere in a script including within user defined functions.
Passing a variable by value means that only a copy of the variable value is passed. The function manipulates the copy and therefore does not effect the value of the variable outside the function.
Passing a variable by reference allows the variable to be changed or created by the function.
The body of the function consists of one or more statements. For details on allowable script statements, see Actions and Statements
Return
A return statement in the body of the function returns control to the caller of the function. The return statement can also return a value to the caller.
return; or return count + 1;
The return statement and return value are optional. However, the user should be aware that the value returned from a function is undefined if no return value is provided or if the last statement executed in the function is not a return statement.
User-defined functions can be defined any place that a pattern-action statement can be defined. For more information on pattern-action statements, Pattern Matching and Action Statements.CXL scripts consist of pattern-action statements and function definitions. User-defined functions can be called from any expression in a pattern. In addition, user defined functions can be called recursively. This means a function can be called in its own body. As with any program that makes recursive calls, coding CXL scripts with recursive function calls should be done with great care.
Last modified date: 10/22/2024