Parameters | Previous Top Next

Most procedure and function headers include a parameter list. For example, in the header
function Power(X: Real; Y: Integer): Real;
the parameter list is (X: Real; Y: Integer).
A parameter list is a sequence of parameter declarations separated by semicolons and enclosed in parentheses. Each declaration is a comma-delimited series of parameter names, followed in most cases by a colon and a type identifier, and in some cases by the = symbol and a default value. Parameter names must be valid identifiers. Any declaration can be preceded by one of the reserved words var, const, and out (see Parameter semantics). Examples:
(X, Y: Real)
(var S: string; X: Integer)
(HWnd: Integer; Text, Caption: PChar; Flags: Integer)
(const P; I: Integer)
The parameter list specifies the number, order, and type of parameters that must be passed to the routine when it is called. If a routine does not take any parameters, omit the identifier list and the parentheses in its declaration:
procedure UpdateRecords;
begin
...
end;
Within the procedure or function body, the parameter names (X and Y in the first example above) can be used as local variables. Do not redeclare the parameter names in the local declarations section of the procedure or function body.