A procedure is a block of ViviFire statements between a declaration clause (
Sub) and an end clause (
Almost all executable statements must be in a procedure.
A module (
Program) can contain executable statements also.
But we recommend a procedure for a program that is larger than an example.
Calling a procedure
You execute a procedure from a different area of the code. This is known as a procedure call. When the procedure completes, it moves control back to the code that executed it, also known as the caller. The caller is a statement (or an expression in a statement) that refers to the procedure by its name and moves control to it.
Returning from a procedure
A procedure gives back control to the caller when it is done.
It can use one of the statements
Exit, or let it execute until the clause
Then control moves to the caller after the point of the procedure call.
Return, control immediately goes back to the caller. Statements after
Returndo not execute. You can have more than one
Returnin the same procedure.
Exit, control immediately goes back to the caller. Statements after
Exitdo not execute. You can have more than one
Exitin the same procedure. Also, you can mix
Exitin the same procedure.
- If a procedure does not have one of the statements
Exit, then it stops at the clause
Endfollows the last statement of the procedure body.
Endimmediately causes control to go back to the caller. You can have only one clause
Endin a procedure.
Parameters and arguments
Types of procedures
- Sub procedures
- Event-handling procedures
- Function procedures
- Method Procedures
- Property Procedures
- Generic procedures
Procedures and structured code