comp.lang.ada
 help / color / mirror / Atom feed
From: "Paul" <pcas1986@bigpond.net.au>
Subject: Re: How to get a key from keyboard
Date: Sat, 29 Nov 2008 06:15:35 GMT
Date: 2008-11-29T06:15:35+00:00	[thread overview]
Message-ID: <b65Yk.1824$Et1.116@news-server.bigpond.net.au> (raw)
In-Reply-To: 49301282$1_1@news.bluewin.ch

The other version of get_immediate works fine for me (GNAT GPL 2008)

I always liked Turbo Pascal.  It was my uni's "learning language" back in 
the mid 80's.  Very fast on an 8086 computer!

If I were going to use the code below I'd probably use the Look_Ahead 
procedure as well.  I recall when I wrote some of this a while back that 
control codes and the like could be tricky.

Paul

with ada.text_io;use ada.text_io;
procedure chartest is
  ch : character := 'Y';
  available : boolean := false;
begin
  put_line("Enter characters");
  while ch /= 'X' loop
    get_immediate(ch, available);
    if available then
      put(ch);
    end if;
  end loop;
  new_line;
  put_line("Done");
end chartest;



"Gautier" <gautier@fakeaddress.nil> wrote in message 
news:49301282$1_1@news.bluewin.ch...
> tolkamp wrote:
>
>> In Pascal there is a function Readkey to read a single character from
>> the keyboard. Is there a simular function in ADA?
>
> NB: ReadKey is a Turbo Pascal thing.
>
>> I have tried the procedure Get_Immediate(Char, Error) but here you
>> have to press the Enter key as well.
>
> Strange... I get immediately each of "[a][b][c][d]..." when pressing each 
> of "abcd...", with the following:
> --
> with Ada.Text_IO; use Ada.Text_IO;
>
> procedure Test_Key is
>   c: Character;
> begin
>   loop
>     Get_Immediate(c);
>     Put('[' & c & ']');
>   end loop;
> end Test_Key;
> --
> Compiled by GNAT, run on Windows.
> _________________________________________________________
> Gautier's Ada programming -- http://sf.net/users/gdemont/
>
> NB: For a direct answer, e-mail address on the Web site! 





  reply	other threads:[~2008-11-29  6:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-28 15:20 How to get a key from keyboard tolkamp
2008-11-28 15:47 ` Gautier
2008-11-29  6:15   ` Paul [this message]
2008-12-01  7:28     ` christoph.grein
2008-12-22 16:22       ` f.tolkamp
2008-12-22 17:40         ` Georg Bauhaus
replies disabled

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