comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey D. Cherry" <jdcherry@utech.net>
Subject: Re: Stopwatch project
Date: 1999/04/26
Date: 1999-04-26T00:00:00+00:00	[thread overview]
Message-ID: <37249B01.4EF5CF28@utech.net> (raw)
In-Reply-To: 924946678.23882.0.nnrp-04.c2de4c02@news.demon.co.uk

Mr. Heaney's test driver does indeed work using GNAT 3.11p under Win95. 
To demonstrate the differences between Get and Get_Immediate, I've
copied Mr. Heaney's test driver and replaced the appropriate procedure
call.  The result is included below.  Try both programs on your system
and observe the difference in behavior.  On my system the behavior is as
follows:
   For the Get version -- The user must press a letter command and then
the 
                          <enter> key before the test driver responds to
the
                          input.  The letter key pressed is echoed to
the 
                          display as is the newline sequence in response
to
                          the <enter> key.
   For the Get_Immediate version -- The test driver responds to a letter
                          command as soon as the key is pressed.  The
letter
                          is not echoed to the display.

Note that both versions have advantages and disadvantages.  You should
perform additional testing on your system to determine which approach
will meet your requirements.  I would recommend you test both drivers
with multiple character inputs.  For example, type in several letter
commands before pressing the <enter> key for the Get version, and enter
the same keys for the Get_Immediate version.  Try invalid keys, function
keys, and redirected input.  Note the behavior in each case.  This
should assist in choosing the most appropriate implementation.

Regards,
Jeffrey D. Cherry
Logicon Geodynamics

-----
with Stopwatch;
with Ada.Text_IO; use Ada.Text_IO;

procedure Test_Stopwatch is
   C : character;
begin -- Test_Stopwatch
   loop
      Get_Immediate(C);
      case C is
         when 'r' | 'R' =>
            Stopwatch.Reset;
            Put_Line ("Stopwatch has been reset.");
         when ' ' =>
            Stopwatch.Start;
            Put_Line ("Stopwatch has been started.");
         when 's' | 'S' =>
            Stopwatch.Stop;
            Put_Line("Stopwatch stopped; total time is " &
               duration'image(Stopwatch.Total_Time) & ".");
         when 'x' | 'X' =>
            exit;
         when others =>
            null;
      end case;
   end loop;
end Test_Stopwatch;
-----




      parent reply	other threads:[~1999-04-26  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-24  0:00 Stopwatch project Brian A Crawford
1999-04-25  0:00 ` Matthew Heaney
1999-04-25  0:00 ` Matthew Heaney
1999-04-26  0:00 ` Jeffrey D. Cherry [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox