Coral 66 Language Reference Manual: For mission-critical applications | ||
---|---|---|
Prev | Chapter 4. Reference to Data | Next |
Certain objects of data may be initialized when the program is loaded into store by the inclusion of a presetting clause in the data declaration. Presetting is not dynamic, and preset values which are altered by program are not reset unless the program or segment is reloaded. An object is not eligible for presetting if it is declared anywhere within
the body of a recursive procedure, or
an inner block of the program, or
an inner block of a procedure body.
Procedure bodies do not count as blocks for the purposes of (b). For example, the integer i is eligible for presetting in a segment which begins as follows:
The preset constants are listed at the end of the declaration after an assignment symbol, and are allocated in the order defined in . As examples,
If desired for legibility, round brackets may be used to group items of the Presetlist, but such brackets are ignored by the compiler. The number of constants in the Presetlist must not exceed, but may be less than, the number of words declared, and presetting ceases when the Presetlist is exhausted. In special cases (see ), the preset assignment symbol may be the only part of the Presetlist which is present. The syntax is
Presetlist
::=
:= Constantlist
Void
Constantlist
::=
Group
Group
, Constantlist
Group
::=
Constant
( Constantlist
)
Void
The main purpose of the final void will be seen in . For the expansion of Constant, see .
There are two alternative mechanisms. If the internal structure of a
table is completely disregarded, the table can be treated as an ordinary
one-dimensional array of whole computer words (see ), and preset as such (see ). Alternatively the table
elements may be preset after their declaration list, as shown at
Elementpresetlist
in the syntax of . For example
TABLE gears [1,3] [ teeth1 UNSIGNED (6) 0,0; teeth2 UNSIGNED (6) 0,6; ratio UNSIGNED (11,5) 0,12; arc UNSIGNED (5,5) 0,12 PRESET (57, 19, 3.0, ), (50, 25, 2.0, ), (45, 30, 1.5, )]
For table-element presetting, the word PRESET is used instead of the assignment symbol of . Each entry of the table is preset in succession as a group of elements, taken in order of their declaration. Voids in the list imply an absence of assignment. This may be necessary to avoid duplication when fields overlap, as do "ratio" and "arc" in the above example. As in , brackets used for grouping constants in the list of presets are ignored by the compiler. The syntax is
Elementpresetlist
::=
PRESET
Constantlist
Void
The previous example could, with equal effect but less convenience, be expressed in the form