09.12.2012 Views

Basic Characteristics RAPID

Basic Characteristics RAPID

Basic Characteristics RAPID

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

5 Data<br />

5.1 Data scope<br />

There are three kinds of data: variables, persistents and constants.<br />

- A variable can be assigned a new value during program execution.<br />

- A persistent can be described as a “persistent” variable. This is accomplished<br />

by letting an update of the value of a persistent automatically cause the initialisation<br />

value of the persistent declaration to be updated. (When a program is<br />

saved the initialisation value of any persistent declaration reflects the current<br />

value of the persistent.)<br />

- A constant represents a static value and cannot be assigned a new value.<br />

A data declaration introduces data by associating a name (identifier) with a data type.<br />

Except for predefined data and loop variables, all data used must be declared.<br />

The scope of data denotes the area in which the data is visible. The optional local directive<br />

of a data declaration classifies data as local (within the module), otherwise it is global.<br />

Note that the local directive may only be used at module level, not inside a routine.<br />

Example: LOCAL VAR num local_variable;<br />

VAR num global_variable;<br />

Data declared outside a routine is called program data. The following scope rules apply<br />

to program data:<br />

- The scope of predefined or global program data may include any module.<br />

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

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

same name (including instructions and predefined routines and data).<br />

Program data may not have the same name as other data or a routine in the same module.<br />

Global program data may not have the same name as other global data or a routine<br />

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

the same program.<br />

Data declared inside a routine is called routine data. Note that the parameters of a routine<br />

are also handled as routine data. The following scope rules apply to routine data:<br />

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

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

name.<br />

See the example in Figure 4.<br />

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

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

Saved successfully!

Ooh no, something went wrong!