home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog2 / blocks.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  2.2 KB  |  72 lines

  1.                                        -- Chapter 9 - Program 3
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure Blocks is
  6.  
  7.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  8.    use Int_IO;
  9.  
  10.    Index, Count : INTEGER;
  11.  
  12. begin
  13.    Index := 27;
  14.    Count := 33;
  15.    Put("In the main block      - values are");
  16.    Put(Index);                                -- Blocks.Index
  17.    Put(Count);                                -- Blocks.Count
  18.    New_Line;
  19.  
  20.    declare
  21.       Index, Stuff : INTEGER := -345;
  22.    begin
  23.       Index := 157;
  24.       Put("In the embedded block  - values are");
  25.       Put(Blocks.Index);                      -- Blocks.Index
  26.       Put(Index);                             -- local Index
  27.       Put(Stuff);                             -- local Stuff
  28.       Put(Count);                             -- Blocks.Count
  29.       New_Line;
  30.    end;
  31.  
  32.    Put("Back to the main block - values are");
  33.    Put(Index);                                -- Blocks.Index
  34.    Put(Count);                                -- Blocks.Count
  35.    New_Line;
  36.  
  37.    Who:                                       -- Block name
  38.    declare
  39.       Index, Stuff : INTEGER := -345;
  40.    begin
  41.       Index := 157;
  42.       Put("In the block named Who - values are");
  43.       Put(Blocks.Index);                      -- Blocks.Index
  44.       Put(Index);                             -- Who.Index
  45.       Put(Who.Index);                         -- Who.Index
  46.       Put(Stuff);                             -- Who.Stuff
  47.       Put(Who.Stuff);                         -- Who.Stuff
  48.       Put(Count);                             -- Blocks.Count
  49.       New_Line;
  50.    end Who;
  51.  
  52.    Put("Back to the main block - values are");
  53.    Put(Index);                                -- Blocks.Index
  54.    Put(Count);                                -- Blocks.Count
  55.    New_Line;
  56.  
  57. end Blocks;
  58.  
  59.  
  60.  
  61.  
  62. -- Result of execution
  63.  
  64. -- In the main block      - values are   27   33
  65. -- In the embedded block  - values are   27  157 -345   33
  66. -- Back to the main block - values are   27   33
  67. -- In the block named Who - values are   27  157  157 -345 -345   33
  68. -- Back to the main block - values are   27   33
  69.  
  70. -- Note; some blanks were removed to fit the data in 70 columns.
  71.  
  72.