Quick start manual

Procedures and functions
6-1
Chapter
6
Chapter6
Procedures and functions
Procedures and functions, referred to collectively as routines, are self-contained
statement blocks that can be called from different locations in a program. A function
is a routine that returns a value when it executes. A procedure is a routine that does
not return a value.
Function calls, because they return a value, can be used as expressions in
assignments and operations. For example,
I := SomeFunction(X);
calls SomeFunction and assigns the result to I. Function calls cannot appear on the left
side of an assignment statement.
Procedure calls—and, when extended syntax is enabled ({$X+}), function calls—can
be used as complete statements. For example,
DoSomething;
calls the DoSomething routine; if DoSomething is a function, its return value is
discarded.
Procedures and functions can call themselves recursively.