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

  1.                                        -- Chapter 6 - Program 1
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure AllInt is
  6.  
  7.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  8.    use Int_IO;
  9.  
  10.    Data  : INTEGER;
  11.    Form  : POSITIVE;
  12.    Once  : NATURAL;
  13.  
  14.    type    MY_INTEGER is range -1000..24000;
  15.    type    MY_SHORT   is range -12..127;
  16.    subtype MY_SUBTYPE is MY_INTEGER range -12..127;
  17.  
  18.    Index : MY_INTEGER := 345;
  19.    Stuff : MY_INTEGER := 33;
  20.    Count : MY_SHORT := 54;
  21.  
  22. begin
  23.    Put("The type MY_SHORT covers the range of");
  24.    Data := INTEGER(MY_SHORT'FIRST);
  25.    Put(Data);
  26.    Put(" to");
  27.    Data := INTEGER(MY_SHORT'LAST);
  28.    Put(Data);
  29.    New_Line;
  30.    Put("and its base covers the range of");
  31.    Data := INTEGER(MY_SHORT'BASE'FIRST);
  32.    Put(Data);
  33.    Put(" to");
  34.    Data := INTEGER(MY_SHORT'BASE'LAST);
  35.    Put(Data);
  36.    New_Line(2);
  37.  
  38.    Put("The type MY_INTEGER covers the range of");
  39.    Put(INTEGER(MY_INTEGER'FIRST));
  40.    Put(" to");
  41.    Put(INTEGER(MY_INTEGER'LAST));
  42.    New_Line;
  43.    Put("and its base covers the range of");
  44.    Put(INTEGER(MY_INTEGER'BASE'FIRST));
  45.    Put(" to");
  46.    Put(INTEGER(MY_INTEGER'BASE'LAST));
  47.    New_Line(2);
  48.  
  49.    if Index in MY_SUBTYPE then
  50.       Put_Line("Index is in the range of MY_SUBTYPE");
  51.    end if;
  52.  
  53.    if Index not in MY_SUBTYPE then
  54.       Put_Line("Index is not in the range of MY_SUBTYPE");
  55.    end if;
  56.  
  57.    if Index in 12..377 then
  58.       Put_Line("Index is in the range of 12..377");
  59.    end if;
  60.  
  61.    if Index not in Stuff..3 * (Stuff - 4) then
  62.       Put_Line("Index is not in the range of Stuff..3 * (Stuff - 4)");
  63.    end if;
  64.  
  65. end AllInt;
  66.  
  67.  
  68.  
  69.  
  70. -- Result of execution
  71.  
  72. -- The type MY_SHORT covers the range of   -12 to   127
  73. -- and its base covers the range of-32768 to 32767
  74. --
  75. -- The type MY_INTEGER covers the range of -1000 to 24000
  76. -- and its base covers the range of-32768 to 32767
  77. --
  78. -- Index is not in the range of MY_SUBTYPE
  79. -- Index is in the range of 12..377
  80. -- Index is not in the range of Stuff..3 * (Stuff - 4)
  81.  
  82.