Variable declarations


 Variable declarations

A variable declaration consists of a list of identifiers that designate new variables (var) and their type.


   X, Y, Z; Real;
   I, J, K: Integer;
   Digit: 0..9;
   C: Color;
   Done,Error: Boolean
   Operator: (Plus, Minus, Times);
   Hue1, Hue2: set of Color;
   Today: Date;
   Matrix: array[1..10, 1..10] of Real;

The type given for the variable(s) can be a type identifier previously declared

  - in a type declaration part in the same block, or
  - in an enclosing block, or
  - in a unit

It can also be a new type definition.

When an identifier is specified within the identifier list of a variable declaration, that identifier is a variable identifier for the block in which the declaration occurs. The variable can then be referred to throughout the block, unless the identifier is redeclared in an enclosed block.

Redeclaration creates a new variable using the same identifier, without affecting the value of the original variable.

See Also

| G+
Код для вставки: :: :: :: ::
Поделиться: // //