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 three levels of definitions:
- common to all the projects installed on your machine
- global to all programs of a project
- local to one program

Common and global definitions can edited from the "File / Open" menu of the main window. 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.

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)

Notes:

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:

__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:

The following ST program sets variables declared as STRING(255):

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

Result:

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