-- 
-- Demonstrates that a global variable is visible within following procedures
-- 
with Ada.Integer_Text_IO; use  Ada.Integer_Text_IO;
with Ada.Text_IO;         use  Ada.Text_IO;

procedure scope is

                        -- Do not declare your variables here!
    i : Integer := 10;  -- a GLOBAL variable, visible to test and scope


    procedure test is
        x: Integer := 5;    -- x is local to test
    begin
                        -- Variable i is GLOBAL
                        --    It is visible in test, but not declared in test
        i := i + x;

        -- put("j=");  put(j);  -- J not visible here.  Must define before use
    end test;

                        -- Declare your variables here!
    j : Integer := 20;  -- visible to scope, but not test

begin

    put("j=");  put(j);  new_line;
    put("i=");  put(i);  new_line;

    test;

    put("i=");  put(i);  new_line;


    -- put(" x="); put(x); new_line;  -- not visible outside test

end scope;
-- Output: 
j=         20
i=         10
i=         15