From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5cd788f18b560297 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!lon-transit.news.telstra.net!lon-in.news.telstra.net!news.telstra.net!news-server.bigpond.net.au!53ab2750!not-for-mail From: "Paul" Newsgroups: comp.lang.ada References: <49301282$1_1@news.bluewin.ch> Subject: Re: How to get a key from keyboard X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-RFC2646: Format=Flowed; Response Message-ID: Date: Sat, 29 Nov 2008 06:15:35 GMT NNTP-Posting-Host: 121.223.178.140 X-Complaints-To: abuse@bigpond.net.au X-Trace: news-server.bigpond.net.au 1227939335 121.223.178.140 (Sat, 29 Nov 2008 17:15:35 EST) NNTP-Posting-Date: Sat, 29 Nov 2008 17:15:35 EST Organization: BigPond Internet Services Xref: g2news1.google.com comp.lang.ada:2839 Date: 2008-11-29T06:15:35+00:00 List-Id: 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" 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!