Previous topic | Ada Home Page | Index

Parameter association - Example

The following program does nothing sensible, but can be used to demonstrate the parameter association mechanisms of Ada.

    ------------------------------------------------------
    -- Program to demonstrate parameter association
    -- Skansholm, page 237
    ------------------------------------------------------

    with TEXT_IO;
    procedure param_demo is

        package int_io is new TEXT_IO.INTEGER_IO(INTEGER);
        use text_io, int_io;

        X, Y, Z : INTEGER;


        procedure nonsense (
            A : in     INTEGER;
            B : in out INTEGER;
            C : out    INTEGER)
        is
        begin
            B := A + B;
            C := 0;
        end nonsense;


    begin -- param_demo
        X :=  1;
        Y :=  5;
        Z := 10;
        put(X); put(Y); put(Z); NEW_LINE;

        nonsense (X,Y,Z);

        put(X); put(Y); put(Z); NEW_LINE;

    end param_demo;

Call to nonsense

initialisation via parameters

Execution of nonsense

statements alter local values

Return from nonsense

final values of out and in out parameters returned


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