2 variable declarations, Variable declarations – Rice Lake iRite IDE User Manual

Page 22

Advertising
background image

18

920i

Programming Reference

A : integer

B : real

end database;

;

Array Type Definitions

An array type definition describes a container for an ordered collection of identically typed objects. The
container is organized as an array of one or more dimensions. All dimensions begin at index 1.

<array-type-definition>:

array '[' <expr-list> ']' of <type>

;

ARRAY

END

expr-list

type

[

]

Figure 3-7. Array Type Definition Syntax

Examples:

type Weights is array [25] of Real;

An array consisting of user-defined records could be defined as follows:

type Employees is array [100] of EmployeeRecord;

A two-dimensional array in which each dimension has an index range of 10 (1…10), for a total of 100 elements
could be defined as follows:

type MyArray is array [10,10] of Integer;

Note

In all of the preceding examples, no variables (objects) are created, no memory is allocated by the type
definitions. The type definition only defines a type for use in a later variable declaration, at which time
memory is allocated.

3.3.2

Variable Declarations

A variable declaration creates an object of a particular type. The type specified must be a previously defined
user- or system-defined type name. The initial value, if specified, must be type-compatible with the declared
object type. All user-defined variables must be declared before being used.

Variables declared with the keyword stored cause memory to be allocated in battery-backed RAM. Stored data
values are retained even after the indicator is powered down.

Variables declared with the keyword constant must have an initial value.

<variable-declaration>:

IDENTIFIER ':' <stored-option> <constant-option> <type>

<optional-initial-value>

;

<stored-option>:

/* NULL */

| stored

;

<constant-option>:

/* NULL */

| constant

;

<optional-initial-value>:

/* NULL */

| := <expr>

;

Example:
MyVariable : StopLightColor;

Advertising
This manual is related to the following products: