09.12.2012 Views

Basic Characteristics RAPID

Basic Characteristics RAPID

Basic Characteristics RAPID

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Basic</strong> <strong>Characteristics</strong> <strong>RAPID</strong> Routines<br />

3 Routines<br />

3.1 Routine scope<br />

There are three types of routines (subprograms): procedures, functions and traps.<br />

- Procedures do not return a value and are used in the context of instructions.<br />

- Functions return a value of a specific type and are used in the context of expressions.<br />

- Trap routines provide a means of dealing with interrupts. A trap routine can be<br />

associated with a specific interrupt and then, if that particular interrupt occurs<br />

at a later stage, will automatically be executed. A trap routine can never be<br />

explicitly called from the program.<br />

The scope of a routine denotes the area in which the routine is visible. The optional<br />

local directive of a routine declaration classifies a routine as local (within the module),<br />

otherwise it is global.<br />

Example: LOCAL PROC local_routine (...<br />

PROC global_routine (...<br />

The following scope rules apply to routines (see the example in Figure 2):<br />

- The scope of a global routine may include any module.<br />

- The scope of a local routine comprises the module in which it is contained.<br />

- Within its scope, a local routine hides any global routine or data with the same<br />

name.<br />

- Within its scope, a routine hides instructions and predefined routines and data<br />

with the same name.<br />

Module1 Module2<br />

Local Routine a<br />

Local Routine b<br />

Routine c<br />

Routine d<br />

Routine e<br />

Local Routine a<br />

Local Routine e<br />

Routine f<br />

Routine g<br />

Routine h<br />

Figure 2 Example: The following routines can be called from Routine h:<br />

Module1 - Routine c, d.<br />

Module2 - All routines.<br />

A routine may not have the same name as another routine or data in the same module.<br />

A global routine may not have the same name as a module or a global routine or global<br />

data in another module.<br />

<strong>RAPID</strong> Reference Manual 5-11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!