# record

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

- The record may contain optional elements which may or may not be present when assigning value to the constructs.
- Element type can be any basic or user-defined data type.
- More elements can have same type as long as their identifiers differ.
- Elements of the record may be accessed using the dot notation, value list notation or assignment notation.
- The sizeof() predefined function returns the actual size of the record type parameter, constant, variable or template.
- The ispresent() predefined function returns the Boolean value true if the referenced optional field is present in the record.
- A record of the same element type may be defined using the keyword of.

Related keywords:

- address
- length
- sizeof
- of
- omit
- optional
- type

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

- The type record keywords introduce the type definition.

- identifier is the name used to refer to the record. Must begin with a letter, may contain letters, numbers and underscore characters.

- address is a user defined type to allow addressing specific entities inside the System Under Test.

- type_reference refers to an already defined (structured or simple) type.

- element_identifier identifies the elements of the record. The identifiers must be unique within the same record

- ... indicates that type_reference element_identifier pairs may be repeated. They are separated by comma.

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

- The type record of keywords introduce the type definition.

- The optional length keyword denotes that the size of the record is restricted.

- record_size is the size restriction. When a single integer value is given, it specifies the exact size of the record. When two integer values are given (separated by two dots), the minimal and the maximal length of the record are given.

- type_reference refers to an already defined (structured or simple) type.

- identifier is the name used to refer to the record. Must begin with a letter, may contain letters, numbers and underscore characters.

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