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

  1.                                        -- Chapter 15 - Program 4
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure Adder3 is
  6.  
  7.    package Flt_IO is new Text_IO.Float_IO(FLOAT);
  8.    use Flt_IO;
  9.  
  10.    FIRST : constant := 2;
  11.    LAST  : constant := 7;
  12.    Sum_Of_Values : FLOAT;
  13.  
  14.                       -- Interface of AdderStb
  15.    package AdderStb is
  16.       type MY_ARRAY is array(INTEGER range <>) of FLOAT;
  17.       procedure Add_Em_Up(In_Dat : in     MY_ARRAY;
  18.                           Sum    :    out FLOAT);
  19.    end AdderStb;
  20.  
  21.  
  22.    use AdderStb;
  23.    New_Array : MY_ARRAY(FIRST..LAST);
  24.  
  25.  
  26.                        -- Implementation of AdderStb
  27.    package body AdderStb is separate;
  28.  
  29.  
  30. begin
  31.    for Index in New_Array'FIRST..New_Array'LAST loop
  32.       New_Array(Index) := FLOAT(Index);
  33.    end loop;
  34.  
  35.    Put_Line("Call Add_Em_Up now.");
  36.    Add_Em_Up(New_Array,Sum_Of_Values);
  37.    Put("Back from Add_Em_Up, total is");
  38.    Put(Sum_Of_Values,5,2,0);
  39.    New_Line;
  40.  
  41. end Adder3;
  42.  
  43.  
  44.  
  45.  
  46. -- Result of execution
  47.  
  48. -- Call Add_Em_Up now
  49. -- Back from Add_Em_Up, total is   27.00
  50.  
  51.