Procedure Declarations

A procedure declaration has the form procedure procedureName(parameterList); directives;

localDeclarations; begin statements end;

where procedureName is any valid identifier, statements is a sequence of statements that execute when the procedure is called, and (parameterList), directives;, and localDeclarations; are optional.

Here is an example of a procedure declaration:

procedure NumString(N: Integer; var S: string); var

V: Integer; begin

S := Chr(V mod 10 + Ord('O')) + S; V := V div 10; until V = 0;

Given this declaration, you can call the NumString procedure like this:

NumString(17, MyString);

This procedure call assigns the value '17' to MyString (which must be a string variable).

Within a procedure's statement block, you can use variables and other identifiers declared in the localDeclarations part of the procedure. You can also use the parameter names from the parameter list (like n and s in the previous example); the parameter list defines a set of local variables, so don't try to redeclare the parameter names in the localDeclarations section. Finally, you can use any identifiers within whose scope the procedure declaration falls.

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment