comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Stopwatch project
Date: 1999/04/25
Date: 1999-04-25T00:00:00+00:00	[thread overview]
Message-ID: <m3hfq4mg5f.fsf@mheaney.ni.net> (raw)
In-Reply-To: 924946678.23882.0.nnrp-04.c2de4c02@news.demon.co.uk

"Brian A Crawford" <brianc@billybob.demon.co.uk> writes:

> I have found on page 914-915 of 'Ada as a Second Language'  a package called
> Stopwatch but find no example on how to use it (and the fact that it is on
> page 914 is not lost on a beginner :-) ).
> 
> Any help would be extremely greatly appreciated.

Here is a test driver.  It does something similar to what you want, but
without using Get_Immediate.

My run-time is broken, so when I run this program, it dumps core.  Try
it yourself and see if it works.

Matt
<mailto:matthew_heaney@acm.org>



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

procedure Test_Stopwatch is

   C : Character;

begin

   Main:
   loop

      Get (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 Main;

         when others =>
            Put_Line ("Bad input.");

      end case;

   end loop Main;

end Test_Stopwatch;




  reply	other threads:[~1999-04-25  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 [this message]
1999-04-25  0:00 ` Matthew Heaney
1999-04-26  0:00 ` Jeffrey D. Cherry
replies disabled

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