[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Subprograms              Procedures and Functions

    There are two types of subprograms: procedures and functions. Both
    follow the same basic syntax:

         <subprogram header>
         <label section>
         <const section>
         <type  section>
         <var   section>
         <subprograms>
         begin
           <main body>
         end;

    where the following definitions hold:

           <header>   A PROCEDURE or FUNCTION header.

    <label section>   The keyboard LABEL followed by a list of labels (1-
                      to 4-digit numbers, separated by commas and ending
                      with a semicolon).

    <const section>   The keyword CONST followed by one or more constant
                      declarations.

     <type section>   The keyword TYPE followed by one more more data type
                      declarations.

      <var section>   The keyword VAR followed by one or more variable
                      declarations.

      <subprograms>   Any number of procedures or functions.

        <main body>   Any number of statements, separated by semicolons.

    In Standard Pascal, each of the sections above--label, const, type,
    var, and subprogram--can appear only once and must appear in the order
    given. If no such declarations are needed--for example, if you have no
    labels--then you can simply omit that section.

    Turbo Pascal is more flexible in its definition of subprogram
    structure. You can freely rearrange the order of the label, const,
    type, var, and  subprogram sections, and you can have multiple
    instances of each.

See Also: programs procedures functions
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson