 -- Copyright 1984 BY ABComputing
 --
 --
 --
 --		     ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
 --		     ³ File Name:  ÛÛ	 list1.ada  ÛÛ	³
 --		     ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
 --
 --
 -- This  program prints a message on your screen. It is intended as a
 -- test  for  your  Ada  compiler.  It  will  work  with Telesoft Ada
 -- unchanged,	although  to  run  it with JANUS/ADA will require some
 -- changes, as described in the JANUS manual.


with TEXT_IO;
procedure MESSAGE is
   use TEXT_IO;
begin
   put ("How are things going so far?");
end MESSAGE;




 -- This  program  illustrates Ada's separate compilation features (as
 -- described  in  this  issue's  Ada  column).  Running  it on either
 -- Telesoft  Ada or JANUS/ADA will require making some changes in the
 -- MESSAGE  program. In  addition, JANUS will require some changes in
 -- this  program.  See  your manual. In either case, you will have to
 -- compile MESSAGE first.


with TEXT_IO, MESSAGE;
procedure ADA_SENDS_HER_GREETINGS is
   use TEXT_IO;
begin
   put ("The Countess asks `");
   MESSAGE;
   put ("'");
end ADA_SENDS_HER_GREETINGS;

 -- -------------------------------------------------------------------------


 -- This program sorts an array of ten integers in ascending order

 -- WARNING:	This program is  written in standard Ada, and WILL NOT
 -- work  with any Ada compiler currently available for the IBM PC. If
 -- you have one of the subset compilers evaluated in the Ada software
 -- review  section  of  this issue, you will find instructions in the
 -- documentation for converting this program to the subset syntax.


with TEXT_IO; use TEXT_IO;
procedure SORT_AN_ARRAY is
   package INT_IO is new INTEGER_IO (integer);
   use INT_IO;
   subtype ONE_TO_TEN is integer range 1..10;
   MINIMUM: integer;
   TEMP: integer;
   N: integer;
   NUMBERS: array(ONE_TO_TEN) of integer;
begin
-- First, we have the user fill up the array.
for I in NUMBERS'RANGE loop -- loop ten times
    put ("enter an integer:");
    get (NUMBERS(I));
end loop;
-- Now, sort the array.
for I in NUMBERS'RANGE loop
    MINIMUM := I;
    for J in MINIMUM+1..NUMBERS'LAST loop
	if NUMBERS(J) < NUMBERS(MINIMUM) then
	   MINIMUM := J;
	end if;
    end loop; -- end of J loop
    -- Swap the values.
    TEMP := NUMBERS(I);
    NUMBERS(I) := NUMBERS(MINIMUM);
    NUMBERS(MINIMUM) := TEMP;
end loop; -- end of I loop
put ("Here is the array in ascending order:");
NEW_LINE;
for I in 1..10 loop  -- another way to loop 10 times
    put NUMBERS(I);
    NEW_LINE;
end loop;
end SORT_AN_ARRAY;

 -- -------------------------------------------------------------------------


 -- This program finds the greatest common divisor of two integers. It
 -- is	intended  as  a  demonstration of Ada's package facility. Note
 -- that  the  package is divided into	two parts - a "specification,"
 -- which provides the interface to other program units wishing to use
 -- the  package,  and a "body," which gives the underlying details of
 -- the package.

 -- Before attempting to compile and run this package, please read the
 -- WARNING given in the SORT_AN_ARRAY routine in this file.


 package FRACTIONS is -- this is the start of the specification
    function GCD (M, N: in integer) return integer;
   -- In a real package, there would be more inside the specification
   -- than a single function. This is just an example, though.
 end FRACTIONS; -- end of specification


 package body FRACTIONS is -- start of the body
    function GCD (M, N: in integer) is
    -- We give the rest of the function here in the body
    begin
       if N = 0 then
	  return M;
       else
	  return GCD (N, M mod N);
       end if;
    end GCD;
 end FRACTIONS; -- end of body


 -- The  following  procedure  makes  use  of  FRACTIONS.  It could be
 -- compiled  by  itself  (as  long  as  FRACTIONS  had  been compiled
 -- earlier) or along with FRACTIONS in the same compilation.


 with TEXT_IO, FRACTIONS; use TEXT_IO, FRACTIONS;
 procedure TRY_GCD is
    package INT_IO is new INTEGER_IO (integer);
    use INT_IO;
    X, Y: integer;
 begin
    loop -- forever
       put ("Enter an integer (0 to quit): ");
       get (X);
       exit when X = 0;
       NEW_LINE;
       put ("And another one: ");
       get (Y);
       NEW_LINE;
       put ("The greatest common divisor is ");
       put (GCD (X, Y)); -- a call to the function in the package
       NEW_LINE;
    end loop;
 end TRY_GCD;
isp  languag