comp.lang.ada
 help / color / mirror / Atom feed
From: darek <darek.maksimiuk@gmail.com>
Subject: Re: Get_Immediate has  raised  CONSTRAINT_ERROR : s-wchcnv.adb:207 explicit raise
Date: Wed, 18 Feb 2015 11:34:34 -0800 (PST)
Date: 2015-02-18T11:34:34-08:00	[thread overview]
Message-ID: <458d2dc3-ecbb-44d1-aaae-75e5fa6b23e9@googlegroups.com> (raw)
In-Reply-To: <1uhwqdsrdxacw$.jmvurilykvf4.dlg@40tude.net>

So, are there any alternatives in Ada (GNAT) that should/may  be used for this trivial task? 

Regards,
  Darek 

On Wednesday, 18 February 2015 19:34:21 UTC+1, Dmitry A. Kazakov  wrote:
> 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 19: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
2015-02-18 19:34   ` darek [this message]
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