Titan



record


The keyword denotes a structured type representing an ordered sequence of elements. Each element consists of a type and an identifier.

Related keywords:


type record  (identifier  | address) {  type_reference  element_identifier [ optional ] ... };


type record  [ length (record_size)of  type_reference  identifier };


Example 1: type definition

type record MyRecordType { 
   integer Number1 optional,
   integer Number2,
   charstring String
}

The record called MyRecordType consists of three elements. The first two are both of type integer and have the identifier Number1 and Number2, respectively. Number1 is optional. The third element is of type character string and has the identifier String.


Example 2: dot notation (For the type definition see example 1)

var MyRecordType v_myRecord; 
v_myRecord.Number1 := omit;
v_myRecord.Number2 := 12;

The variable v_myRecord of type MyRecordType is defined. The first field (Number1) is omitted and the value 12 is assigned to the field Number2.


Example 3: assignment notation (For the type and variable definition see example 1 & 2)

v_myRecord := {Number2 := 112};

The value 112 is assigned to the field Number2. 


Example 4: value list notation  (For the type and variable definition see example 1 & 2)

v_myRecord := {omit, -, ""};

In the value list notation no elements may be absent, dropped optional elements (here: Number1) must explicitly be omitted using the omit keyword. A field value remains unchanged when the 'not-used' symbol (–) is applied (here: Number2). The last field will contain an empty string.


Example 5: the predefined function sizeof()

v_myRecord := {omit, 191, "s"};
var integer v_Stk := sizeof (v_myRecord);

The variable v_Stk equals two as there are two elements in v_myRecord (the first one is omitted).


Example 6: the predefined function ispresent()

v_myRecord := {omit, 191, "s"};
var boolean v_kukuccs := ispresent (v_myRecord.Number1);

The variable v_kukuccs equals false as there the referenced element in v_myRecord (Number1) is omitted.


Example 7: record of the same element type 

type record length (3) of integer IntegerList;
var IntegerList v_il := { 71, 92, 83};
var integer v_elem := v_il[1];

A record of three integers is defined. The record is called IntegerList. 
To assign values to the elements of the record, value list notation is used. The elements of the record will have the value 71, 92 and 83, respectively. 
Individual elements of the record may be accessed using the array notation. In the example above the variable v_elem will have the value 92.



BNF definition of record
BNF definition of record of