4.6. Presetting

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

  1. the body of a recursive procedure, or

  2. an inner block of the program, or

  3. 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:


BEGIN PROCEDURE f;
    BEGIN PROCEDURE g;
        BEGIN INTEGER i;

4.6.1. Presetting of Simple References and Arrays

The preset constants are listed at the end of the declaration after an assignment symbol, and are allocated in the order defined in Section 4.5. As examples,


INTEGER a, b, c := 1, 2, 3;
INTEGER ARRAY k[1:2, 1:2] := 11, 12, 21, 22

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 Section 4.7), 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 Section 4.6.2. For the expansion of Constant, see Section 10.2.

4.6.2. Presetting of Tables

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 Section 4.4.4), and preset as such (see Section 4.6.1). Alternatively the table elements may be preset after their declaration list, as shown at Elementpresetlist in the syntax of Section 4.4.1. 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 Section 4.6.1. 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 Section 4.6.1, 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


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 ]
:= OCTAL(1402371), OCTAL(1003162), OCTAL(603655)