comp.lang.ada
 help / color / mirror / Atom feed
From: jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk)
Subject: Re: Troubles : New_Page & Get_Immediate
Date: 1997/10/18
Date: 1997-10-18T00:00:00+00:00	[thread overview]
Message-ID: <877158990.60snx@jvdsys.nextjk.stuyts.nl> (raw)
In-Reply-To: 01bcdae4$3f70ffa0$0f02000a@default


In article <01bcdae4$3f70ffa0$0f02000a@default> bjyxxl@echidna.stu.cowan.edu.au writes:

>The LRM states that Get_Immediate can be used to get a character from the
>keyboard immediately ie. without the enter key.   But says should be used
>with 'unbuffered' input.   Are there any references or suggestions as to
>how to do low_level IO or 'unbuffered' input to do this.  End goal to have
>something like the well known 'hit any key to continue'.

As this was asked twice:

a) Get_Immediate comes in two flavors: blocking and non-blocking.

   The blocking form waits until a key is pressed befor returning

   The non-blocking form returns immediately, reporting if a keypress
   was detected.

   Here's a simple example of both:

      with Ada.Text_IO; use Ada.Text_IO;

      procedure Test is
         C         : Character;
         Available : Boolean := False;
      begin

         -- Waiting for a key pressed - blocking
         Put ("Press almost any key to continu: ");
         Get_Immediate(C);
         New_Line;
         Put_Line ("Ok, continuing...");

         -- Polling for a key pressed - non-blocking
         Put ("Again waiting for some keypress: ");
         While not Available loop
            -- Do useful things here
            Get_Immediate (C, Available);
         end loop;
         New_Line;
         Put_Line ("Ok, thanks for pressing a key.");
      end Test;

The buffered/unbufferd issue gives a compiler the option of
not implementing this, but wait for an Enter key to be
pressed first.

Fortunately for you, both OA Special and GNAT support the
(IMHO) proper behavior with their Win95/NT compilers.

--

-- Jerry van Dijk | Leiden, Holland
-- Consultant     | Team Ada
-- Ordina Finance | jdijk@acm.org




  reply	other threads:[~1997-10-18  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-17  0:00 Troubles : New_Page & Get_Immediate Ray Tindall
1997-10-18  0:00 ` Jerry van Dijk [this message]
1997-10-18  0:00 ` Jerry van Dijk
1997-10-20  0:00   ` Anonymous
1997-10-21  0:00     ` Jerry van Dijk
1997-10-20  0:00   ` John English
replies disabled

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