Booleans


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.

Table E-1: DCL's interpretation of data as Boolean values

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.




Getting Started with OpenVMS System Management
Getting Started with OpenVMS System Management (HP Technologies)
ISBN: 1555582818
EAN: 2147483647
Year: 2004
Pages: 130
Authors: David Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net