info.mailtraq.com > Management > Script Functions A-Z > Define() Define()Creates a new user-defined function which must be expressed before being used elsewhere in the script or template. Function definitions can be shared with references to external scripts. Any number of parameters can be passed to the defined function. The parameters are referred to by the placeholders $1, $2, $3, etc, within the function definition. The number of parameters provided by the function call is held in the $0 placeholder. Note that Mailtraq passes parameters by their address not by their value.
Define( function , content )
- function
- The name, as a string, of the function being defined
- content
- The function expressions. Use the Do() function to bind multiple expressions
// Defines a function which repeats the given
// string a specified number of times. If a number is not given, the default of '5' is used.
Define("RepeatLine",
Do(
local_i := If($0 < 2, 5, $2),
While(local_i > 0,
Do(
local_i := local_i - 1,
$1 ++ "\n"
)
)
)
);
RepeatLine( "Repeated Line", 3);
RepeatLine( "Another Repeated Line") |