Alias Definitions
An alias is a unique
identifier that can be used in programs to replace another text. Definitions are
typically used to replace a constant expression and facilitate the maintenance of
programs.
There are three levels of definitions:
- Common to all the projects present on your machine
- Global to all programs within your project
- Local to one program
Local definitions are edited together with the corresponding program.
Definitions are entered in a text editor. Each definition must be entered on one line of text according to the following syntax:
#define Identifier Equivalence (* comments *)
Below are some examples:
#define OFF FALSE (* redefinition of FALSE constant *) #define PI 3.14 (* numerical constant *) #define ALARM (bLevel > 100) (* complex expression *)
You can use a definition within the contents of another definition. The definition used in the other one must be declared first. Below is an example:
#define PI 3.14 #define TWOPI (PI * 2.0)
Note that a definition can be empty, for example:
#define CONDITION
The defined word can be used for directing the conditional compiling directives.
-
-
You can enter #define lines directly in the source code of programs in IL "Instruction list" This is a low-level language and resembles assembly or ST "Structured text" A high-level language that is block structured and syntactically resembles Pascal languages.
The use of definitions can disturb the program monitoring and make error reports more complex. It is recommended to restrict the use of definitions to simple expressions that do not risk creating a misunderstanding when reading or debugging a program.