A record is a data structure (like an array) which can store values with different data types.

Each item in a record is called an attribute (or field). Each attribute is given an identifier (name) and data type.

Records are fixed in length. Attributes cannot be added or deleted, but they can be changed.


Example 1 shows how to create a record structure.

Example 1
RECORD film
  name: STRING
  releaseYear: INT
  duration: INT
  rating: REAL
ENDRECORD


Example 2 shows how to assign values to the record.

Example 2
film.name ← "Avengers: Endgame"
film.releaseYear ← 2019
film.duration ← 182
film.rating ← 8.4


Example 3 shows how to manipulate records.

Example 3
OUTPUT film
>>> {name: "Avengers: Endgame",
     releaseYear: 2019,
     duration: 182,
     rating: 8.4}


OUTPUT film.rating
>>> 8.4

film.rating ← 8.3
OUTPUT film.rating
>>> 8.3



What would be wrong with writing film.rating ← "8.5"?

The rating attribute needs to be of the REAL type, but "8.5" is a string.