Calling Functions and Procedures
To call a function or procedure, just write its name into the script, followed by the list of arguments, enclosed in round parentheses (...)
. The number of arguments must match the requirements of the function/procedure. If no arguments are required, then the parentheses are still required – even with nothing between them.
Functions return a value. Usually the script processes this value. To do so, you can assign it to a variable or use it in an expression. However, sometimes the script wants to ignore the value which the function returns. In this case, do not assign it.
Procedures, unlike functions, do not return a value. It is an error to assign a procedure “return value” to a variable because such “return value” doesn’t exist.
Script-defined functions are called like built-in functions.
Examples:
%guid = makeguid() // The makeguid function does not take any parameters
%len = strlen("Hello world") // The strlen function takes a string value and returns its length
OpenTable("LocalTable") // The OpenTable procedure takes 1 or 2 parameters; being a procedure, it doesn't return a value
%total_length = strlen("Hello") + strlen("world") // Function return values can be used in expressions
MessageBox(strcat("The number is ", 42)) // The result of the strcat function can be used as argument to another function; the return value of the MessageBox function is ignored