Previous topic | Next topic | Ada Home Page | Index

Procedures

Procedure Definition

Example

    procedure  show_answer   is

        -- display the result of adding two numbers

    begin  -- show_answer

        NEW_LINE;
        PUT ( "The total is .... ");
        PUT ( total_num ); 
        NEW_LINE;

    end show_answer;

Procedure Call

procedure call:

procedure must be visible:

Procedure call and return

procedure call:

  1. remember where up to in the calling code
  2. transfer to called procedure
    1. set up storage for local variables
    2. associate parameters with values
    3. start execution at first statement of callee

procedure finishes executing:

  1. wind up called procedure
    1. return values through parameters
    2. dispose of storage
  2. pick up where left off in caller


Previous topic | Next topic | Ada Home Page | Index
c-lokan@adfa.oz.au / 15 Feb 96