* How do I read in a character w/out pressing return ?
@ 1990-11-19 12:31 Arne Gehlhaar
1990-11-21 19:25 ` Andy DeFaria
0 siblings, 1 reply; 2+ messages in thread
From: Arne Gehlhaar @ 1990-11-19 12:31 UTC (permalink / raw)
Hello
I have Question concerning the input of characters. I wrote a little
program, to scan through a sequential file, and want to be able to
go forward and backward. So I wrote :
direction : character;
get(direction);
case ...
The thing is though, that I have to press return every time I enter
the "command". Is there any way I can make the program accept just
a 'touch of a button'? I tried looking at the text_io file, but it
turned out, that the thing is a little more complicated than I expected.
As far as I know, there is no ADA command that allows me to do that.
Is there a way of getting around that ?
Thanks for any replys!
Greetings
Arne
received data 988 bytes 5.95 secs
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How do I read in a character w/out pressing return ?
1990-11-19 12:31 How do I read in a character w/out pressing return ? Arne Gehlhaar
@ 1990-11-21 19:25 ` Andy DeFaria
0 siblings, 0 replies; 2+ messages in thread
From: Andy DeFaria @ 1990-11-21 19:25 UTC (permalink / raw)
Seems we just went through this discussion a little while back.
There is no good way to do it using pure Ada. The best way to accomplish
this, IMHO, is to interface with the OS system call that reads a character.
Encapsulate this procedures (GET_KEY) into a package (SYSTEM_CALLS) to
minimize and localize portablity concerns. The Ada call will 1) insure the
types coming in and going out are correct and pragma INTERFACE to the
correct system call (depending, of course, on the OS in question).
so (hypothetical example, assume reasonable type definitions):
package SYSTEM_CALLS is
type STATUS_TYPE is new INTEGER;
type CHAR_PTR is access CHARACTER;
OK : constant STATUS_TYPE := 0;
function GET_KEY (THE_CHARACTER : in CHAR_PTR) return STATUS_TYPE;
pragma INTERFACE (C, GET_KEY);
pragma INTERFACE_NAME (GET_KEY, "getchar");
end SYSTEM_CALLS;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1990-11-21 19:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1990-11-19 12:31 How do I read in a character w/out pressing return ? Arne Gehlhaar
1990-11-21 19:25 ` Andy DeFaria
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox