O'Reilly logo

Delphi for .NET Developer’s Guide by Xavier Pacheco

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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): ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required