Function Procedures

A Function procedure is a series of ViviFire statements enclosed by Function and End Function clauses.

The Function procedure performs a task, then returns control to the calling code (known as the "caller"). When it returns, the procedure returns a value to the caller.

Each time the procedure is called, its statements are executed, beginning with the first executable statement after the Function clause. Execution normally proceeds until it encounters the End Function clause; however, it can be halted by either an Exit Function or Return statement.

You can define a Function procedure in modules, classes, objects, and traits. It is private, meaning that it can be called only by other code in the enclosing class, object, or trait, or module if not otherwise enclosed.

A Function procedure can take arguments, such as constants, variables, or expressions, which are passed to it by the caller.

Declaration syntax

Function function_name [ parameter_list ]
    ' statements
End Function

You define the parameter list much like you would for Sub Procedures.

Data type


Returning a value


Calling syntax


Example of declaration and call


See also