* Unbuffered keyboard input on VAX ADA?
@ 1995-01-27 7:05 Jake E. Hamby
0 siblings, 0 replies; 3+ messages in thread
From: Jake E. Hamby @ 1995-01-27 7:05 UTC (permalink / raw)
Does anyone know a way to get unbuffered keyboard input (i.e. one
character at a time without waiting for ENTER) using DEC Ada 83 for
VAX/VMS? Our curriculum at Cal Poly Pomona uses Ada, and NONE of the
students/faculty has found an answer to this seemingly simple problem.
Perhaps it's possible to import a foreign C function to do the input, but
I would like to have an Ada-only solution. Does anyone know how to do
this? Please send E-Mail, I will post a reply. Thanks in advance!
--
=========================================================================
* Jake Hamby - "Linux: The Choice of a GNU Generation" *
* E-MAIL: jehamby@lightside.com + jehamby@vms4.sci.csupomona.edu *
* http://vms4.sci.csupomona.edu/~jehamby/index.html *
^ permalink raw reply [flat|nested] 3+ messages in thread
* Unbuffered keyboard input on VAX ADA?
@ 1995-02-02 0:40 Jake E. Hamby
[not found] ` <1995Feb3.103003.9017@eisner>
0 siblings, 1 reply; 3+ messages in thread
From: Jake E. Hamby @ 1995-02-02 0:40 UTC (permalink / raw)
Okay, thanks for all the responses I got. Basically, everyone used the
same low-level VMS system calls from packages STARLET and SYSTEM to read
the input, so the programs all looked pretty much identical. By the
way, Ada 9X has the Get_Immediate procedure in TEXT_IO, but of course
VAX Ada is only Ada 83, so it has to resort to such a kludge. Here is the
example written by jrg@sema-grenoble.fr:
with SYSTEM;
with TEXT_IO;
with CONDITION_HANDLING;
with STARLET;
with TASKING_SERVICES;
package body ADS_DIAL_IO is
function TO_ULW ( X : SYSTEM.ADDRESS ) return SYSTEM.UNSIGNED_LONGWORD
renames SYSTEM.TO_UNSIGNED_LONGWORD;
CLAVIER : STARLET.CHANNEL_TYPE; clavier = keyboard in french
ITEMLIST: STARLET.ITEM_LIST_TYPE(0..1);
function TRANSLATE_STATUS (STATUS : CONDITION_HANDLING.COND_VALUE_TYPE)
return STRING is
ST_GETMSG : CONDITION_HANDLING.COND_VALUE_TYPE;
TEXT_ST : STRING (1..132);
TEXT_RET : STRING (1..80) := ( others => ' ' );
LG_TEXT_ST : SYSTEM.UNSIGNED_WORD;
begin
-- translate status => string
STARLET.GETMSG
( STATUS => ST_GETMSG,
MSGID => STATUS,
MSGLEN => LG_TEXT_ST,
BUFADR => TEXT_ST );
if CONDITION_HANDLING.SUCCESS (ST_GETMSG) then
if INTEGER(LG_TEXT_ST) < TEXT_RET'LENGTH then
TEXT_RET (1..INTEGER(LG_TEXT_ST)) := TEXT_ST(1..INTEGER(LG_TEXT_ST));
else
TEXT_RET := TEXT_ST(1..TEXT_RET'LENGTH);
end if;
else
TEXT_RET (1..32) := "Error in TRANSLATE_STATUS";
end if;
return TEXT_RET;
end TRANSLATE_STATUS ;
function GETKEY return CHARACTER
is
STATUS : CONDITION_HANDLING.COND_VALUE_TYPE;
IOSB : STARLET.IOSB_TYPE;
TXT : STRING ( 1 .. 10 );
FUNC : constant := STARLET.IO_READVBLK + STARLET.IO_M_EXTEND ;
begin
TASKING_SERVICES.TASK_QIOW
( STATUS => STATUS,
CHAN => CLAVIER,
FUNC => FUNC,
IOSB => IOSB,
P1 => TO_ULW( TXT'address ),
P2 => SYSTEM.UNSIGNED_LONGWORD( TXT'length ) ,
P5 => TO_ULW( ITEMLIST'address ),
P6 => SYSTEM.UNSIGNED_LONGWORD( ITEMLIST'size/8 ) );
if not CONDITION_HANDLING.SUCCESS ( STATUS ) then
TEXT_IO.PUT_LINE ("TASK_QIOW: " & TRANSLATE_STATUS( STATUS ) ) ;
end if ;
return TXT( 1 );
end GETKEY;
begin
STARLET.ASSIGN( STAT,
"TT:",
CLAVIER ); -- assign channel for keyboard
-- QIO read initialisation
ITEMLIST(0).BUF_LEN:= 0;
ITEMLIST(0).ITEM_CODE:= STARLET.TRM_ESCTRMOVR;
ITEMLIST(0).BUF_ADDRESS:= SYSTEM.TO_ADDRESS(9);
ITEMLIST(0).RET_ADDRESS:= SYSTEM.ADDRESS_ZERO;
ITEMLIST(1).BUF_LEN:= 0;
ITEMLIST(1).ITEM_CODE:= STARLET.TRM_MODIFIERS;
ITEMLIST(1).BUF_ADDRESS:= SYSTEM.TO_ADDRESS(
STARLET.TRM_M_TM_ESCAPE +
STARLET.TRM_M_TM_NOECHO +
STARLET.TRM_M_TM_CVTLOW +
STARLET.TRM_M_TM_PURGE +
STARLET.TRM_M_TM_NOFILTR );
ITEMLIST(1).RET_ADDRESS:= SYSTEM.ADDRESS_ZERO;
end ADS_DIAL_IO;
--
* Jake Hamby - "Linux: The Choice of a GNU Generation" *
* E-MAIL: jehamby@lightside.com + jehamby@vms4.sci.csupomona.edu *
* http://vms4.sci.csupomona.edu/~jehamby/index.html *
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Unbuffered keyboard input on VAX ADA?
[not found] ` <EMERY.95Feb3123217@goldfinger.mitre.org>
@ 1995-02-10 12:35 ` Larry Kilgallen, LJK Software
0 siblings, 0 replies; 3+ messages in thread
From: Larry Kilgallen, LJK Software @ 1995-02-10 12:35 UTC (permalink / raw)
In article <EMERY.95Feb3123217@goldfinger.mitre.org>, emery@goldfinger.mitre.org (David Emery) writes:
> This example indicates why, in my opinion, such "thin bindings" are A
> Bad Thing.
I presume you refer to the fact that there are two status codes to be
checked (actually the TASKING_* bindings cited by one user are not all
that thin, being developed specifically for Ada tasking support).
Regardless of possible rearrangement of the parameters, asynchronous
IO will always require two status checks on VMS (or any other OS, so
far as I can see), one for when the request is queued and one for when
it is completed. If the request does not get queued, the event which
indicates completion (AST for VMS) will never happen.
Of course an exception could be raised in place of one of the failure
returns if it was extremely unlikely, but that probability cannot
be predicted by the designer of bindings. While the class problem
which started this presumed there was a single keyboard, in a real
situation there could be a score of keyboards, some potentially in
use by other jobs on the computer system at the time when I/O is
requested.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1995-02-10 12:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-02-02 0:40 Unbuffered keyboard input on VAX ADA? Jake E. Hamby
[not found] ` <1995Feb3.103003.9017@eisner>
[not found] ` <EMERY.95Feb3123217@goldfinger.mitre.org>
1995-02-10 12:35 ` Larry Kilgallen, LJK Software
-- strict thread matches above, loose matches on Subject: below --
1995-01-27 7:05 Jake E. Hamby
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox