Procedure statement

Description

Procedure statements execute procedures (which may involve passing actual parameters to the procedures formal parameters). Procedure statements are executed as follows:

  1. First, the actual parameters, if present, are passed to the formal parameters, of the procedure. If the procedure has no formal parameters then this step is skipped.
  2. Next, program execution is transfered to the first statement in the procedure's block.
  3. Execution of the procedure statement is terminated when either the execution of the last statement in the procedure's block is terminated, or when one of the statements in the procedure's block transfers program execution to a statement outside of the procedure's block.

Example

   writeln('1 + 1 = ', 1+1)

is a simple example. When this procedure statement is executed the actual parameters

   '1 + 1 = '

and

   1+1

are passed to the procedure and then the procedure prints the actual parameters to the file associated with output.

Syntax

(NOTE: for clarity some parts of the syntax are omitted, see Irie Pascal Grammar for the full syntax):

   procedure-statement = procedure-identifier (
      [ actual-parameter-list ] |
      read-parameter-list | readln-parameter-list |
      write-parameter-list | writeln-parameter-list
   )

   actual-parameter = expression | variable-access |
       procedure-identifier | function-identifier

   actual-parameter-list = '(' actual-parameter { ',' actual-parameter } ')'

   function-identifier = identifier

   procedure-identifier = identifier

   read-parameter-list = '(' [ file-variable ',' ] variable-access { ',' variable-access } ')'

   readln-parameter-list = [ '(' ( file-variable | variable-access ) { ',' variable-access } ')' ]

   write-parameter = expression [ ':' expression [ ':' expression ] ]

   write-parameter-list = '(' [ file-variable ',' ] write-parameter { ',' write-parameter } ')'

   writeln-parameter-list = [ '(' ( file-variable | write-parameter ) { ',' write-parameter } ')' ]