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

  1.                                        -- Chapter 15 - Program 2
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. with AdderPkg;
  6. use AdderPkg;
  7.  
  8. procedure Adder1 is
  9.  
  10.    package Flt_IO is new Text_IO.Float_IO(FLOAT);
  11.    use Flt_IO;
  12.  
  13.    FIRST : constant := 2;
  14.    LAST  : constant := 7;
  15.    Sum_Of_Values : FLOAT;
  16.  
  17.    New_Array : MY_ARRAY(FIRST..LAST);
  18.  
  19.    procedure Summer(In_Dat : MY_ARRAY;
  20.                     Sum    : out FLOAT) renames AdderPkg.Add_Em_Up;
  21. begin
  22.    for Index in New_Array'FIRST..New_Array'LAST loop
  23.       New_Array(Index) := FLOAT(Index);
  24.    end loop;
  25.  
  26.    Put_Line("Call Add_Em_Up now.");
  27.    Add_Em_Up(New_Array,Sum_Of_Values);
  28.    Put("Back from Add_Em_Up, total is");
  29.    Put(Sum_Of_Values,5,2,0);
  30.    New_Line;
  31.  
  32.           -- The next three statements are identical
  33.    Add_Em_Up(New_Array,Sum_Of_Values);
  34.    AdderPkg.Add_Em_Up(New_Array,Sum_Of_Values);
  35.    Summer(New_Array,Sum_Of_Values);
  36.  
  37. end Adder1;
  38.  
  39.  
  40.  
  41.  
  42. -- Result of execution
  43.  
  44. -- Call Add_Em_Up now
  45. -- Back from Add_Em_Up, total is   27.00
  46.  
  47.