From: johnherro@aol.com (John Herro)
Subject: Re: Getting a single key stroke
Date: 1996/05/05
Date: 1996-05-05T00:00:00+00:00 [thread overview]
Message-ID: <4mj956$687@newsbf02.news.aol.com> (raw)
In-Reply-To: 4metj6$ll5@netra.oscs.montana.edu
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
next prev parent reply other threads:[~1996-05-05 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-05-04 0:00 Getting a single key stroke James Eder
1996-05-05 0:00 ` John Herro [this message]
1996-05-05 0:00 ` Robert Dewar
1996-05-06 0:00 ` David Emery
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox