Sign in Join
Wiki copytemporary

Var

Deutsch · English · Español · Français · Suomi · Русский · 中文(中国)

The keyword var is used to:

Variable declaration section

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

pascal
var
    age: integer;

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

pascal
var
    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.

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

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


From the Free Pascal wiki, page "Var", as it stood on 2021-07-04 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.