function (reserved word)


 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 the identifier for the function, the formal parameters (if any), and the function result type.

Valid result types are ordinal, real, string, and pointer.

A function is activated by the evaluation of a function call in an expression.

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 forward, external, far, or inline directive.


 (* Function declaration *)
 function UpCaseStr(S: string): string;
   I: Integer;
   for I := 1 to Length(S) do
   if (S[I] >= 'a') and (S[I] <= 'z') then
   Dec(S[I], 32);
   UpCaseStr := S;

Тэги: function
| G+
Код для вставки: :: :: :: ::
Поделиться: // //