Previous: 2.2.11.5. Import Units To the Table of Contents Next: 2.2.12.1. Declaration
2.2.11.5. Import Units Table of Contents 2.2.12.1. Declaration

- 2.2.12. -
Table of Contents
2. TMT Pascal Language Description
2.2. Pascal Language Structure
2.2.12. Procedures and Functions


2.2.12. Procedures and Functions


Procedures are a sequence of instructions that are separate from the main code block. Functions are procedures that return a value. Other than this difference, both procedures and functions are the same.

Procedures are blocks of code that are called from one or more places throughout your program. Procedures make source code more readable and reduce the size of the executable because repetitive blocks of code are replaced with a call to a procedure. Both procedures and functions accept parameters. Parameters allow the calling routine to communicate with a procedure.

Parameters can be passed by value or by reference or by constant reference.

If passed by value, only the value of the parameter is passed and the procedure has no access to the actual variable. One can modify the value parameter. It will have an effect only inside of the procedure body and will not change the actual variable.

If passed by reference, also known as var parameters, an address of the memory location containing the value is passed thus making it possible to modify the variable.

If passed by constant reference, also known as const parameters, an address of the memory location containing the value is passed but the compiler does not allow one to modify a constant parameter and does not allow passing one as an actual variable parameter to another procedure or function.

Procedures and Functions Declaration
Forward Declaration
External Declaration
Interrupt Procedure
Procedural Value
Using Statement as Procedure


Previous: 2.2.11.5. Import Units To the Table of Contents Next: 2.2.12.1. Declaration
2.2.11.5. Import Units Table of Contents 2.2.12.1. Declaration

- 2.2.12. -