The Boolean data type encompasses the two logic values true and false. Logical values are important in programming because true/false, yes/no decisions are constantly being made by a program in order to guide its flow of execution. Many conventional programming languages distinguish the Boolean data type from other data types, but DCL does not. However, the Boolean data type can be simulated using the integer and character string data types. Whenever DCL needs a true/false value to use with a logical operation, it accepts an integer or character string and interprets it as true or false depending on its value.
Table E-1 specifies how this interpretation is made.
Boolean value | Data so interpreted |
---|---|
TRUE | Odd integers; character strings beginning with t, T, y or Y; character strings representing odd integers (e.g., "381") |
FALSE | Even integers; all other character strings |
The following data items are considered true:
1 3 "True" "Y" "Yes" "yupsters"
The following are considered false:
0 2 "False" "N" "No" "nope" "random!nonsense" "380"
Symbolic literals for the two Boolean values true and false round out the simulation of the Boolean data type. DCL provides no such literals, so the authors choose the symbols TRUE and FALSE to represent them. Thses symbols can be established with the assignment command described in the next section.