Node:var, Next:view, Previous:value, Up:Reference
As part of a variable declaration part or in a statement block:
var variable_identifier: type_identifier;or
var variable_identifier: type_definition;and with initializing value:
var variable_identifier: type_identifier value constant_expression;or
var variable_identifier: type_definition value constant_expression;
As part of a parameter list (passing by reference):
var var_parameter: type_identifier;or without type declaration
var var_parameter;
or protected (i.e., the called routine can't modify the parameter):
protected var var_parameter: type_identifier;or without type declaration
protected var var_parameter;
In a declaration part: The reserved word var
declares a
variable_identifier whose type is of type_identifier or
which is defined by type_definition. For further description
see Variable Declaration, Type Declaration,
Type Definition, Data Types.
In a parameter list: see Subroutine Parameter List Declaration.
var
is defined in ISO 7185 Pascal and supported by
all known Pascal variants. Untyped var
parameters in
parameter lists are a UCSD Pascal extension. The ability to do
var
declarations in a statement block is a GNU Pascal
extension.
program VarDemo; type FooType = Integer; var Bar: FooType; ArrayFoo: array [0 .. 9] of Integer; { array var definition } FecordFoo: record { record var definition } Bar: Integer end; CharsetFoo: set of Char; { set var } SubrangeFoo: -123 .. 456; { subrange var } EnumeratedFoo: (Mon, Tue, Wed, Thu, Fri, Sat, Sun); {enumerated var } PointerBar: ^FooType; { pointer var } procedure ReadFoo (var Foo: FooType); begin ReadLn (Foo) end; begin var Bar: Integer; { GNU Pascal extension } Bar := 42 end.