Elementary Data Types - User-Defined

User-defined elementary data types are based entirely on predefined elementary data types. You define your own data types using the TYPES statement.

User-defined elementary data types make your programs easier to read and maintain:

TYPES: NUMBER TYPE I,
LENGTH TYPE P DECIMALS 2,
CODE(3) TYPE C.

.......

DATA: NO_FLIGHTS TYPE NUMBER,
NO_PASSENGERS TYPE NUMBER,

      DISTANCE TYPE LENGTH,
HEIGHT TYPE LENGTH,
....
      CITY_CODE TYPE CODE,
COUNTRY_CODE TYPE CODE,

     ......

In this example, a data type called NUMBER is defined. It is the same as the predefined data type I, except it has a different name to make the program easier to read.

Also defined in this example is a data type LENGTH which is based on the predefined elementary data type P. LENGTH is defined with a given number of decimals. If it becomes necessary to change the accuracy of length specifications, for example, you only have to change the TYPES statement in the program.

A third data type, CODE, is also defined. CODE is based on the predefined type C, with a given length of 3.