next up previous contents index
Next: Initialising Variables Up: DATA Statement Previous: DATA Statement

Defined and Undefined Values

The value of each variable and array element is undefined at the start of execution unless it has been initialised with a DATA statement. An undefined value may only be used in executable statements in ways which cause it to become defined. An item can become defined by its use in any of the following ways:

An undefined variable must not be used in any other way. Errors caused by the inadvertent use of undefined values are easy to make and sometimes have very obscure effects. It is important, therefore, to identify every item which needs to be initialised and provide a suitable set of DATA statements.

Modern operating systems often clear the area of memory into which they load a program to prevent unauthorized access to the data used in the preceding job. A few operating systems preset their memory to a bit-pattern which corresponds to an illegal numerical value: this is a very helpful diagnostic facility since whenever an undefined variable is used in an expression it generates an error at run time. Other systems merely set their memory to zero: this makes it more difficult to track down the use of undefined variables and they may only come to light when a program is transported to another system. To rely on undefined variables and arrays having an initial value of zero is to leave the program completely at the mercy of changes to the operating system.


next up previous contents index
Next: Initialising Variables Up: DATA Statement Previous: DATA Statement
Helen Rowlands
8/27/1998