From Free Pascal wiki
Jump to navigationJump to search

Deutsch (de) English (en) español (es) suomi (fi) français (fr) русский (ru) 中文(中国大陆)‎ (zh_CN)

The keyword var is used to:

  • start section of variable declarations, and
  • declare a formal parameter as penetrating mutable.

Variable declaration section

In a block the word var starts a section of one or more variable declarations.

	age: integer;

Variables bearing the same data type can be grouped, by separating their respective identifiers by a comma:

	firstName, lastName, address: string;

Variable parameter

The word var prior a formal parameter declaration indicates that this parameter is variable, that means assigning values to it will affect the named parameter at the call site.

procedure censor(var xxx: longWord);
	if (xxx = $4655434B) or (xxx = $6675636B) then
		xxx := $2A2A2A2A;

After invoking procedure censor the value of the variable that was supplied at the call site (i. e. where the procedure was called) will (possibly) have changed, too.

See also