home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adav313.zip / gnat-3_13p-os2-bin-20010916.zip / emx / gnat / examples / tef.adb < prev    next >
Text File  |  2000-07-19  |  1KB  |  44 lines

  1. --  tef.adb
  2. --  a simple test to use the non-generic elementary function package and call 
  3. --  the some trig functions. Similar to tgef.adb except here there is no 
  4. --  instantiation of GEF (Generic ELementary Functions).
  5.  
  6. with Ada.Numerics.Elementary_Functions;
  7. with Ada.Numerics; use Ada.Numerics;
  8. with Text_IO;
  9. procedure Tef is
  10.    Y : Float;
  11.    P : Integer;
  12.    subtype Line is String (1 .. 80);
  13.    Filler  : Line := (others => ' ');
  14.    Display : array (0 .. 24) of Line;
  15. begin
  16.    Text_IO.Set_Page_Length (Text_IO.Current_Output, 0);
  17.    Text_IO.Put_Line ("Display of Sin, Cos and Arctan graphs");
  18.    Text_IO.Put_Line ("Legend: Sin (O), Cos (X), Arctan (+)");
  19.  
  20.  
  21.    for I in Display'range loop
  22.       Display (I) := Filler;
  23.    end loop;
  24.  
  25.    Display (10) := (1 .. 80 => '-');
  26.  
  27.    for I in 1 .. 20 loop
  28.       Y := Elementary_Functions.Cos (Float (I) * Pi / 10.0);
  29.       P := Integer (10.0 * Y) + 10;
  30.       Display (P)(4 * I) := 'O';
  31.       Y := Elementary_Functions.Sin (Float (I) * Pi / 10.0);
  32.       P := Integer (10.0 * Y) + 10;
  33.       Display (P)(4 * I) := 'X';
  34.       Y := Elementary_Functions.Arctan (Float (I) * Pi / 10.0);
  35.       P := Integer (10.0 * Y) + 10;
  36.       Display (P)(4 * I) := '+';
  37.    end loop;
  38.  
  39.    for I in  Display'range loop
  40.       Text_IO.Put_Line (Display (I));
  41.    end loop;
  42.  
  43. end Tef;
  44.