9618 · 13.1
User-defined data types
Instead of just using basic data types like INTEGER or STRING, we can create our own custom data types to group related information together. This makes our code much cleaner, more logical, and easier to understand, just like organising files into a specific folder.
Need to know
What you need to know
- A record is a composite data type.
- It groups multiple variables (fields) into a single unit.
- Fields can have different data types (e.g., a mix of `STRING`, `INTEGER`, `DATE`).
- This allows us to model real-world objects like a student, a car, or a product.
Explanation
Build Your Own Data Blueprints
- Identify related data items you want to group, like a student's name, ID, and date of birth.
- Define a new composite data type using the `TYPE` and `ENDTYPE` keywords, listing each field and its base data type.
- Declare a variable of your new custom type, just as you would declare an integer or string variable.
- Access and manipulate the individual fields within the variable using dot notation, for example `MyStudent.Name`.