Executes statements defined in the function procedure and returns a value.
[ x = ] FuncName ( [ Arguments ] )
Zero or more Arguments separated by commas.
A function procedure can return any simple type, but cannot return an array or structure.
A function is a procedure which returns a value. A function call can be used as a stand alone statement, for example:
FUNCT1(argument_list)
or as a value in an expression.
x = FUNCT1(argument_list) + y
Even though a procedure returns a value, you do not have to use it.
If the procedure has any type other than VOID, for example, Long, then it must return a value of that type.
For a detailed description of how the arguments are passed to the procedure parameters, how optional parameters are handled, etc., see Subroutine Call.
After the parameters are initialized, control is transferred to the first statement of the procedure. The statements of the procedure are executed until a Return statement is encountered. The Return statement must have an expression. The value of the return expression is converted to the type of the function if necessary, control returns to the calling code, and the returned value is used in any subsequent calculations required to evaluate the expression which contained the function call. If the return value is not of interest for a particular call, the function can be called as if it were a subroutine procedure.
In the following example, the Mid internal function arguments are first evaluated. Then the Mid function is called. Finally, the Val is called and passed to the Print statement.
Print Val(Mid(s, i, i+10), 10)