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

  1.                        -- Chapter 27 - Programming exercise 1
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure CH27_1 is
  6.  
  7. task type SHORT_LINE is
  8. end SHORT_LINE;
  9.  
  10. task type LONG_LINE is
  11. end LONG_LINE;
  12.  
  13. Cow                    : array (1..17) of SHORT_LINE;
  14. Elephant, Hippopotamus : LONG_LINE;
  15.  
  16. task body SHORT_LINE is
  17. begin
  18.    for Index in 1..4 loop
  19.       delay 0.0;
  20.       Put_Line("This is a short line");
  21.    end loop;
  22. end SHORT_LINE;
  23.  
  24. task body LONG_LINE is
  25. begin
  26.    for Index in 1..3 loop
  27.       delay 0.0;
  28.       Put_Line("This is a much longer line to be displayed");
  29.    end loop;
  30. end LONG_LINE;
  31.  
  32. begin
  33.    Put_Line("This is an example of use of a task type array");
  34. end CH27_1;
  35.  
  36.  
  37.  
  38.  
  39. -- Result of execution
  40.  
  41. -- This is an example of use of a task type
  42. -- The output is similar to the program TASKARRY.ADA but there
  43. --   is a lot more of it.
  44.  
  45. -- Note that 17 was the largest number that could be used for
  46. --   the number of tasks and still execute properly.  When the
  47. --   number 18 is used, a storage_error exception is generated.
  48. --   This is for one compiler, and the number could vary over a
  49. --   rather large range for different compilers.
  50.  
  51.