Each value has a data type that determines which operations can be performed on the value and the way in which the value is represented in storage.
Data types are declared for variables, function results, named constants (such as files), and external procedures. They are also used with the ENTRY attribute to describe the data type of each parameter of a procedure.
Data types are declared using the following attributes:
Computational Data | Non-Computational Data |
---|---|
FIXED BINARY | POINTER |
FIXED DECIMAL | LABEL |
FLOAT BINARY | ENTRY |
FLOAT DECIMAL | FILE |
PICTURE | OFFSET |
CHARACTER | AREA |
CHARACTER VARYING | |
WIDECHAR | AREA |
WIDECHAR VARYING | |
BIT |
The attributes in the first column represent data items whose values can be manipulated by arithmetic or string operations and are therefore computational. The attributes in the second column refer to data used within a program for control structures and linkage and are therefore non-computational.
The data type of a value produced by an expression is determined by the operands and the built-in functions within the expression. The data type of a constant is determined by the syntax of the constant.
A variable capable of storing only one value, such as an integer or a character string, at any one time is called a scalar variable. An array variable is a collection of variables all of the same type. For example, an array might consist of 20 individual character strings. The variables contained in the array are called elements of the array. These elements all have the same name as the array. They are ordered by a numeric index, or perhaps several indices, and they are referenced by use of these indices. A structure variable is a collection of variables of arbitrarily mixed types. The variables contained in a structure are called members of the structure. The members each have their own name. A member may be referenced by its name alone, or its name may be qualified by the structure name to distinguish it from a member of another structure. A structure can contain subordinate structures as members, as well as array members and scalar members. Also, the elements of an array can be structures.
This chapter discusses each data type, beginning with computational data types.