Definitions
The compiler supports the definition of aliases. An alias is a unique identifier that can be used in programs to replace another text. Definitions are typically used for replacing a constant expression and ease the maintenance of programs.
There are two levels of definitions:
- Global to all programs of a project.
- Local to one program.
Local definitions are edited together with the corresponding program. Use the View / Local Defines menu command when editing a program to open its local definitions.
Hint: Alias declared as global define can be used as variable name in a fieldbus configuration. An alias can replace a full variable name or an index in case of an array element.
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 *)
|
#define OFF FALSE (* redefinition of FALSE constant *) Please note: There is no semicolon (;) at the end of the expression. |
You can use a definition within the contents of another definition. The definition used in the other one must be declared first.
|
#define PI 3.14 |
|
A definition may be empty, for example: #define CONDITION 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 or ST languages. The use of definitions may disturb the program monitoring and make error reports more complex. It is recommended to restrict the use of definitions to simple expressions that have no risk to lead to a misunderstanding when reading or debugging a program. |
System definitions
The following words are predefined by the compiler and can be used in the programs:
Word |
Description |
__DATE__ |
Date stamp of compiling expressed as a string constant expression |
__MACHINE__ |
Name of the machine where compiling is run, expressed as a string constant expression. |
__USER__ |
Name of the user where compiling is run, expressed as a string constant expression. |
__APPNAME__ |
Name of the project, expressed as a string constant expression. |
|
The following ST program sets variables declared as STRING(255): strDate := __DATE__; Result: strDate is '2007/11/25-10:45' |
|
Definitions |
IEC 61131-3 Automation platform > IEC 61131-3 Programming Environment > Definitions |
Created with the Personal Edition of HelpNDoc: Free iPhone documentation generator