Was this helpful?
User-Defined Functions
Users have the ability to define their own functions in CXL scripts by using the CXL User Defined Function Language Element. In creating the functions, the user defines the parameters, body and return value of the function. User Defined Functions allow the user to customize the CXL scripts to the user’s specific needs.
The format of user-defined functions is as follows:
function name(parameter-list) {
statements; #body section
}
The word function is a required keyword. Name, parameter-list, and statements in the syntax above are user defined. The name is the name that will be used when the function is called in the script. The user defined function name cannot start with ‘$’ character. The parameter-list immediately follows the name and is enclosed in parenthesis. The function name and the left parenthesis of the parameter list cannot have any blanks between them. This is required to allow CXL to distinguish between user-defined functions and user defined variables. The parameter-list consists of zero to many variables separated by commas.
Rules and Limitations for Variables in a User Defined Function
Parameter list variables are local.
Any variables defined within the function are local.
Other variables in a CXL script are global, but will be passed by value only to a user-defined function.
Field variables, like $1, $2, …, are passed by value only.
An array element other than array[0] or array["0"] must be accessed prior to using the array as a parameter in a function call.
Single dimensional arrays are passed by reference.
Multidimensional arrays are passed by value.
A function cannot be used as a parameter.
Last modified date: 11/01/2022