Sign in Join
Wiki copytemporary

Procedure

Deutsch · English · Français · Italiano · Suomi · Русский

A procedure is a routine that does not return a value. procedure is a reserved word.

Prematurely leaving a procedure

In a procedure the routine exit can be called in order to (prematurely) leave the procedure. exit may not be supplied with any parameters, since procedures do not return any value, but functions do. Supplying a parameter to exit inside a procedure definition will yield the compile-time error “Error: Procedures cannot return a value”.

Invocation

Procedure calls are statements. They may not appear in expressions, since they do not produce a value of any kind. The following example highlights all lines with procedure calls.

pascal
program procedureDemo(input, output, stderr);

var
    x: longint;

procedure foo;
begin
    exit;
    inc(x);
end;

begin
    x := 42;
    foo;
    writeLn(x);
end.

Note, that foo contains unreachable code (inc(x) is never executed because of the [unconditional] exit).

See also


From the Free Pascal wiki, page "Procedure", as it stood on 2023-01-25 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.