comp.lang.ada
 help / color / mirror / Atom feed
From: christoph.grein@eurocopter.com
Subject: Re: How to get a key from keyboard
Date: Sun, 30 Nov 2008 23:28:34 -0800 (PST)
Date: 2008-11-30T23:28:34-08:00	[thread overview]
Message-ID: <f1c4d01c-b9ea-4149-98b4-7a37a72e25d6@20g2000yqt.googlegroups.com> (raw)
In-Reply-To: b65Yk.1824$Et1.116@news-server.bigpond.net.au

A.10.7
 (9) procedure Get_Immediate(File : in File_Type;
                            Item : out Character);
     procedure Get_Immediate(Item : out Character);

(10) Reads the next character, either control or graphic, from the
specified File or the default input file. Mode_Error is propagated if
the mode of the file is not In_File. End_Error is propagated if at the
end of the file. The current column, line and page numbers for the
file are not affected.

(11) procedure Get_Immediate(File : in File_Type;
                             Item : out Character;
                             Available : out Boolean);
     procedure Get_Immediate(Item : out Character;
                             Available : out Boolean);

(12) If a character, either control or graphic, is available from the
specified File or the default input file, then the character is read;
Available is True and Item contains the value of this character. If a
character is not available, then Available is False and the value of
Item is not specified. Mode_Error is propagated if the mode of the
file is not In_File. End_Error is propagated if at the end of the
file. The current column, line and page numbers for the file are not
affected.

Thus the former procedures block if there is no character available,
the latter ones don't.

Try:

  loop
    get_immediate (C);
    Put (Integer'Image (Character'Pos (c)));
  end loop;

Which compiler do you use? If you run the above within GPS, you must
press <enter> - otherwise GPS obviously does not forward the input to
the executable (note that GPS echoes the input and you can edit the
input line with <backspace>). If you run it from a terminal window,
you can press any key and immediately get the result (for some keys,
you'll get more than one number) and there is no echo of your input
and no editing.



  reply	other threads:[~2008-12-01  7:28 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
2008-12-01  7:28     ` christoph.grein [this message]
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