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

  1.                           -- Chapter 15 - Programming example 1
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure CH15_1A 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 Package1
  15.    package AdderPkg 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 AdderPkg;
  20.  
  21.  
  22.    use CH15_1A.AdderPkg;
  23.    New_Array : MY_ARRAY(FIRST..LAST);
  24.  
  25.  
  26.                        -- Implementation of Package1
  27.    package body AdderPkg is separate;
  28.  
  29. begin
  30.    for Index in New_Array'FIRST..New_Array'LAST loop
  31.       New_Array(Index) := FLOAT(Index);
  32.    end loop;
  33.  
  34.    Put_Line("Call Add_Em_Up now.");
  35.    Add_Em_Up(New_Array,Sum_Of_Values);
  36.    Put("Back from Add_Em_Up, total is");
  37.    Put(Sum_Of_Values,5,2,0);
  38.    New_Line;
  39.  
  40. end CH15_1A;
  41.  
  42.  
  43.  
  44.  
  45. -- Result of execution
  46.  
  47. -- Call Add_Em_Up now
  48. -- Back from Add_Em_Up, total is   27.00
  49.  
  50.