IPB

> function (reserved word)
Чат
Форум
Загрузка...
 

Language:
Русский
English

 function (reserved word)


A function is a program part that computes and returns a value.

Syntax

 function ident : type;

OR

 function ident (parameters) : type;

Remarks

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.

Example

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

 
 К началу страницы 
Тэги: function
 

Код для вставки: :: :: :: ГОСТ ::
Поделиться: //
 



-
Хостинг предоставлен компанией "Веб Сервис Центр" при поддержке компании "ДокЛаб"