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.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6b8df82ba3cba40f X-Google-Attributes: gid103376,public From: johnherro@aol.com (John Herro) Subject: Re: Getting a single key stroke Date: 1996/05/05 Message-ID: <4mj956$687@newsbf02.news.aol.com>#1/1 X-Deja-AN: 153171181 sender: root@newsbf02.news.aol.com references: <4metj6$ll5@netra.oscs.montana.edu> organization: America Online, Inc. (1-800-827-6364) newsgroups: comp.lang.ada Date: 1996-05-05T00:00:00+00:00 List-Id: gje9947@msu.oscs.montana.edu (James Eder) writes: > How do you, in Ada, get a single keystroke > such as an arrow key from the user? Oh, > and it must be a somewhat portable method. > I'm writing the program for an open VMS > system with an Ada 83 compiler. I don't think it's possible to get a single keystroke in a "somewhat portable" manner in Ada 83. Even in Ada 95, which has a "portable" routine to do that, there are no guarantees that the routine will work on all systems! Here's how I did it in VAX Ada [83] for VMS in my Ada Tutor program. Unfortunately, this isn't portable. Sorry, it's as close as I can come to what you want: package Custom_IO is ... procedure Get(Char : out Character); ... end Custom_IO; with Starlet, System; use Starlet, System; package body Custom_IO is Chan : Starlet.Channel_Type; IOSB : System.Unsigned_Quadword; Stat : System.Unsigned_Longword; procedure QIOW( Stat : out Unsigned_Longword; EFN : in Integer; Chan : in Channel_Type; Func : in Short_Integer; IOSB : out Unsigned_Quadword; ASTadr : in Integer; ASTPRM : in Integer; P1 : in out String; P2, P3 : in Integer; P4 : in Unsigned_Quadword; P5, P6 : in Integer); pragma Interface(System_Library, QIOW); pragma Import_Valued_Procedure( Internal => QIOW, External => "SYS$QIOW", Parameter_Types => ( Unsigned_Longword, Integer, Channel_Type, Short_Integer, Unsigned_Quadword, Integer, Integer, String, Integer, Integer, Unsigned_Quadword, Integer, Integer), Mechanism => ( Value, Value, Value, Value, Reference, Value, Reference, Reference, Value, Reference, Reference, Reference, Reference)); procedure Get(Char : out Character) is S : String(1 .. 1); begin QIOW(Stat, 0, Chan, 16#7A#, IOSB, 0, 0, S, 1, 0, (0,0), 0, 0); Char := S(1); end Get; ... end Custom_IO; It appears that, for the portion of the package that I posted, the "use Starlet, System;" clause may be unnecessary. However, I no longer have access to VMS to test this. I hope that this helps, or at least that it's better than nothing. - John Herro Software Innovations Technology http://members.aol.com/AdaTutor ftp://members.aol.com/AdaTutor