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.

Listing 5.1 demonstrates a short Delphi program with a procedure and a function.

Listing 5.1. An Example of a Function and a Procedure
1: program FuncProc; 2: 3: {$APPTYPE CONSOLE} 4: 5: procedure BiggerThanTen(I: Integer); 6: { writes something to the screen if I is greater than 10 } 7: begin 8: if I > 10 then 9: writeln('Funky.'); 10: end; 11: 12: function IsPositive(I: Integer): ...

Get Delphi for .NET 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.