Procedures and Functions

As a programmer, you should already be familiar with the basics of procedures and functions. A procedure is a discrete program part that performs some particular task when it's called and then returns to the calling part of your code. A function works the same except that a function returns a value after its exit to the calling part of the program.

If you're familiar with C or C++, consider that a Pascal procedure is equivalent to a C or C++ function that returns void, whereas a function corresponds to a C or C++ function that has a return value.

Listing 2.1 demonstrates a short Pascal program with a procedure and a function.

Listing 2.1. An Example of Functions and Procedures
Program FuncProc; { $APPTYPE CONSOLE} procedure ...

Get Borland® Delphi™ 6 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.