comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Get_Immediate has  raised  CONSTRAINT_ERROR : s-wchcnv.adb:207 explicit raise
Date: Wed, 18 Feb 2015 19:34:15 +0100
Date: 2015-02-18T19:34:15+01:00	[thread overview]
Message-ID: <1uhwqdsrdxacw$.jmvurilykvf4.dlg@40tude.net> (raw)
In-Reply-To: 234cdad3-5c41-4b0d-b611-01c53273cb7f@googlegroups.com

On Wed, 18 Feb 2015 09:29:50 -0800 (PST), darek wrote:

> reading from a keyboard  keys such as arrow keys, PgUp, PgDn, etc. seems
> to be a small challenge in Ada.  For this purpose one of the 
> Get_Immediate procedures from the Ada.Text_IO shall be used.

shall?

> For the
> keyboard we can use either 
>   - procedure Get_Immediate  (Item : out Character) 
>                or
>   - procedure Get_Immediate  (Item : out Character; Available : out Boolean)
> 
> When I have used the Get_Immediate procedure with the extra  boolean
> parameter, it  generates the constraint error for:
>   - all arrow keys, PgUp, PgDn 
>   - [ character from the keyboard !!!!
> 
> Is this a feature or a bug. How pressing a legal key can cause such a
> weird result? 

Neither, I suppose.

AFAIK, RM does not mandate any specific mapping of non-character keyboard
keys or, for that matter, any events from any possible input devices
(mouse, joystick, pen, motion detector...) onto the type Character. Except
for formatting keys (e.g. ones generating CR, LF, HT etc)

> The Get_Immediate procedure without the boolean parameter works fine but
> it waits for a key to be pressed. 
>
> Any ideas how to avoid the problem with this exception? Am I missing something?

Yes. Page Up/Down are not a characters. No key necessarily is, however,
some keys may have corresponding characters, or sequences of characters.

You shall not use Text_IO for keyboard input, unless under some ASCII
terminal emulator, e.g. VT52 or VT100.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2015-02-18 18:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-18 17:29 Get_Immediate has raised CONSTRAINT_ERROR : s-wchcnv.adb:207 explicit raise darek
2015-02-18 18:34 ` Dmitry A. Kazakov [this message]
2015-02-18 19:34   ` darek
2015-02-18 20:36     ` Dmitry A. Kazakov
2015-02-18 21:19       ` darek
2015-02-18 21:44         ` Dmitry A. Kazakov
2015-02-18 22:09       ` Georg Bauhaus
2015-02-18 20:16 ` Simon Wright
2015-02-18 20:34   ` darek
2015-02-19 21:37 ` Björn Lundin
replies disabled

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