$$OUT=-

$$START!

IV. Записи (RECORD)

IV. Records

IV. 1. Декларация записи

IV. 1. Declaration of a record

 

Синтаксис.

 

RECORD {name|_of_record} :
    поле1
    поле2
    ...
    поле N .

 

Записи декларируются внутри классов.

Имя записи всегда начинается со строчной буквы.

Имя записи может делиться значком '|' на две части: часть до знака является кратким именем. Полное имя не должно быть короче 8 символов.

Все декларации записей в классе всегда доступны для использования в любых классах, использующих этот класс.

 

Запись состоит из:

  • полей простых типов фиксированного размера (BOOL, BYTE, INT, REAL, перечисления, STR с модификатором MAXLEN[n])
  • полей типа запись (любые другие записи в области видимости - рекурсивное вложение не допускается)
  • массивов фиксированного размера из выше перечисленных элементов.

 

Декларация записи завершается точкой.

 

 

Syntax.

 

RECORD {name|_of_record} :
    field1
    field2
    ...
    field N .

 

Records are declared in a class body.

Name of a record is always start from a small letter.

The name can be separated with the symbol '|': the first part is a short name of the record. Full name of a record can not be shorter then 8 characters.

All the records declared in a class are always accessible for all the classes importing that class.

 

A record contains of:

  • fields of simple data types of fixed size (BOOL, BYTE, INT, REAL, enumerations, STR with a modifier MAXLEN[n])
  • fields of record types (any other records in a scope of view but recursive nesting is not allowed)
  • arrays of fixed size of the listed above items.

 

A record declaration is ended with the dot symbol '.'.

 

 

IV. 2. Работа с записями

IV. 2. Working with records

 

Записи могут использоваться везде, где могут использоваться простые переменные базовых типов. В частности, функция может возвращать запись, и при приёме записи в качестве параметра, все её поля доступны внутри функции только для чтения.

 

Records can be used in all the positions where simple data types can be used. In part, a function can return a record as a result, and if a record is a parameter of a function, all its fields are read only in the function called.

 

Одна запись может быть присвоена другой записи того же типа оператором простого присваивания. Переменной типа запись может быть присвоена запись, конструируемая на лету с помощью "конструктора записи":
Destination = {record_type}(Field1 = Value1,
    Field2 = Value2, ...)

 

Например:

 

One record variable can be assigned to another record variable of the same type using a simple assignment statement. And it is possible to assign a constructed on a fly record to a record variable using a constructor:
Destination = {record_type}(Field1 = Value1,
    Field2 = Value2, ...)

 

E.g.:

RECORD {person|_info} :
    STR F|irst_name, MAXLEN[40]
    STR L|ast_name, MAXLEN[40]
    INT Y|ear_birthday
    {education} E|ducation
    STR S|tate_province, MAXLEN[2] .

...

{person} Smith = {person}(F = "John", L = "Smith",
               Y=1950, E='High', S = "NY")
 
 

Такой же конструктор может использоваться при передаче фактического параметра функции в позиции параметра типа запись.

 

A similar constructor can be used to pass an actual parameter to a function in place of a record parameter.

$$STOP!