function (reserved word)
A function is a program part that computes and returns a value.
function ident : type;
function ident (parameters) : type;
The function heading specifies thefor the function, the formal (if any), and the function result .
Valid result types are, , , and .
A function is activated by the evaluation of a function call in an.
The function heading is followed by:
- a declaration part that declares local objects
- the statement part, which specifies the statements to be executed when
the function is called
The statement part should contain at least one statement that assigns a value to the function identifier; the result of the function is the last value assigned.
Instead of the declaration and statement parts, a function declaration can specify a, , far, or directive.
(* Function declaration *)
function UpCaseStr(S: string): string;
for I := 1 to Length(S) do
if (S[I] >= 'a') and (S[I] <= 'z') then
UpCaseStr := S;