- A custom type is a collection of data items that may consist of different data types, grouped under one identifier.
- It allows programmers to define complex structures beyond atomic types.
Declaration
TYPE <identifier1>
DECLARE <identifier2> : <data type>
DECLARE <identifier3> : <data type>
ENDTYPE
Usage
- Once defined, a custom type can be used like any other data type in variable declarations.
- Variables of a custom type can be assigned to each other.
- Individual data items are accessed using dot notation.
Example:
TYPE Student
DECLARE name : STRING
DECLARE age : INTEGER
ENDTYPE
DECLARE student1 : Student
DECLARE student2 : Student
student1.name <-- "Yashvi"
student1.age <-- 18
student2 <-- student1 // Assigns all fields of student1 to student2
No comments:
Post a Comment