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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.236.17.135 with SMTP id j7mr852246yhj.21.1424288074364; Wed, 18 Feb 2015 11:34:34 -0800 (PST) X-Received: by 10.140.32.71 with SMTP id g65mr41234qgg.31.1424288074325; Wed, 18 Feb 2015 11:34:34 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!j7no1417759qaq.1!news-out.google.com!c1ni7qar.1!nntp.google.com!i13no2092342qae.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 18 Feb 2015 11:34:34 -0800 (PST) In-Reply-To: <1uhwqdsrdxacw$.jmvurilykvf4.dlg@40tude.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=84.106.97.11; posting-account=-iT6ZQoAAAAlqBCInAc-vB6x1soT8Jhq NNTP-Posting-Host: 84.106.97.11 References: <234cdad3-5c41-4b0d-b611-01c53273cb7f@googlegroups.com> <1uhwqdsrdxacw$.jmvurilykvf4.dlg@40tude.net> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <458d2dc3-ecbb-44d1-aaae-75e5fa6b23e9@googlegroups.com> Subject: Re: Get_Immediate has raised CONSTRAINT_ERROR : s-wchcnv.adb:207 explicit raise From: darek Injection-Date: Wed, 18 Feb 2015 19:34:34 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Received-Bytes: 3075 X-Received-Body-CRC: 3959382961 Xref: news.eternal-september.org comp.lang.ada:24980 Date: 2015-02-18T11:34:34-08:00 List-Id: 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