Alias Definitions

The compiler supports the definition of aliases.

  • An alias is a unique identifier used in programs to replace another text.
    • Definitions are typically used to replace a constant expression and facilitate the maintenance of programs.
    • See usage in (➜ # 1, Use the Defines List) for more information.

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 following this syntax:
#define Identifier Equivalence (* comments *)

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.

Example

#define PI     3.14
#define TWOPI  (PI * 2.0)
  • A definition can be empty

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 or ST 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.

Word

Description

_DATE_

Date stamp of compiling expressed as a string constant expression.

Format is: Year/Month/Day-Hours-Minutes.

_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.

Example

This ST program sets variables declared as STRING(255):

   strDate := __DATE__;
   strMachine := __MACHINE__;
   strUser := __USER__;
strProject := __APPNAME__;

Result:
strDate is '2007/11/25-10:45'
strMachine is 'LaptopJX'
strUser is 'John'