Procedures
A procedure is a block of ViviFire statements between a declaration clause (Function
, Method
, Property
, Sub
) and an end clause (End
).
Almost all control statements must be in a procedure.
A module (Program
) can contain control statements also.
But we recommend a procedure for a program that is larger than a small example.
Calling a procedure
You run 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 Return
or Exit
, or let it run until the clause End
.
Then control moves to the caller after the point of the procedure call.
- With
Return
, control immediately goes back to the caller. Statements afterReturn
do not run. You can have more than oneReturn
in the same procedure. - With
Exit
, control immediately goes back to the caller. Statements afterExit
do not run. You can have more than oneExit
in the same procedure. Also, you can mixReturn
andExit
in the same procedure. - If a procedure does not have one of the statements
Return
orExit
, it stops at the lineEnd
.End
follows the last statement of the procedure body.End
immediately causes control to go back to the caller. You can have only one clauseEnd
in a procedure.
Parameters and arguments
TODO
Types of procedures
- Sub procedures
- Event-handling procedures
- Function procedures
- Method Procedures
- Property Procedures
- Generic procedures
Procedures and structured code
TODO