The procedures
Procedures are blocks of code that can be called several times and from multiple locations in the graph. A procedure is a subroutine which, unlike the functions, does not return a value at the end of its execution.
A procedure can be declared anywhere on the graph. The form for declaring a procedure is as follows:
- Proc Name(s)
For example:
- Proc Test(x)
"Proc" is the keyword that always identifies a procedure or function. The "Test" label is the name of the procedure. The parameter "x" is the data that is passed to the code of the procedure. The parameters of a procedure are declared as local variables of the procedure.
A Procedure can have one, more or no parameters.
- Proc Name(x)
Single parameter procedure
- Proc Name(x,y,z)
Procedure with three parameters.
- Proc Name()
Procedure without parameters.
A procedure always ends with the keyword "EndProc". For example:
- Proc Test(x)
- ...
- EndProc
The variables instantiated inside a procedure are local variables that can only be used inside it. For example:
- Proc Test(x)
- y = 50
- Circle(x,y,20)
- EndProc
A procedure can be called from the main body of the graph and/or from the internal code of another procedure. For example:
- Test(50)
-
- Proc Hello()
- Test(25)
- EndProc
-
- Proc Test(x)
- Circle(x,50,30)
- EndProc
Procedures and functions can recall themselves in a recursive cycle, direct or indirect. Recursive cycles are monitored to avoid infinite loops. You can use recursion up to 256 times.