[comp.os.vms] keyboard interrupt

fsimmons@umn-d-ub.D.UMN.EDU (Frank Simmons) (02/02/88)

 Can anyone tell me if VMS has a routine that will let me test whether
or not the return key has been hit?




Frank Simmons                      BITNET: FSIMMONS@UMNDUL
UMD Information Services           CSNET : fsimmons@ub.d.umn.edu
Univ of Minn,Duluth                ATT   : (218) 726-8849/7587
10 University Drive                SYSTEM : VAX/VMS 4.5  JNET 3.0
Duluth MN 55812

woo@amelia.nas.nasa.gov (Alex Woo) (02/02/88)

Can someone send me a VMS routine (preferably PASCAL) which
acts like the BASIC routine INKEY?  I just want to know if
a key as been depressed, and what character or arrow or
function key?

Alex Woo

P.S.  Don't blame me for this, I'm asking for a friend.

terrell@musky2.EDU (Roger Terrell) (02/03/88)

In article <190@umn-d-ub.D.UMN.EDU> fsimmons@umn-d-ub.D.UMN.EDU (Frank Simmons) writes:
>
> Can anyone tell me if VMS has a routine that will let me test whether
>or not the return key has been hit?
>

Depending (of course) on what you are trying to do, you might want to
use SMG$ENABLE_UNSOLICITED_INPUT.  If input is detected when not
solicited, then call SMG$READ_KEYSTROKE (or some other read function)
and find out what that character(s) was.

--Roger


-- 

Roger Terrell
Muskingum College			...cbosgd!musky2!terrell (UUCP)
New Concord, OH  43762

u3369429@murdu.OZ (Michael Bednarek) (02/03/88)

In article <190@umn-d-ub.D.UMN.EDU> fsimmons@umn-d-ub.D.UMN.EDU (Frank Simmons)
writes:
> Can anyone tell me if VMS has a routine that will let me test whether
>or not the return key has been hit?

In article <161@amelia.nas.nasa.gov> woo@amelia.nas.nasa.gov (Alex Woo) writes:
>Can someone send me a VMS routine (preferably PASCAL) which
>acts like the BASIC routine INKEY?

Here are two Fortran subroutines, SENSE_TYPE_AHEAD and INKEY0, and a
main program, TINKEY0, which should do what you want.

I included SENSE_TYPE_AHEAD only for educational purposes, it is not necessary
if the calling program observes INKEY0's returned status.

(I called it INKEY0 because I already had a subroutine INKEY, which also
does a 1-character-read, but without timeout.)


Michael Bednarek		
Institute of Applied Economic and Social Research (IAESR)
Melbourne University, Parkville 3052, AUSTRALIA, Phone : +61 3 344 5744
Domain: u3369429@{murdu.oz.au | ucsvc.dn.mu.oz.au}  or  mb@munnari.oz.au
"bang": ...UUNET.UU.NET!munnari!{murdu.oz | ucsvc.dn.mu.oz}!u3369429

"POST NO BILLS."

...................... Cut between dotted lines and save ......................
$!.............................................................................
$! VAX/VMS archive file created by VMS_SHAR V-5.03 07-Oct-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by U3369429 (Michael Bednarek)
$! on Wednesday 3-FEB-1988 16:12:39.33
$!
$! It contains the following 3 files:
$! SENSE_TYPE_AHEAD.FOR INKEY0.FOR TINKEY0.FOR
$!=============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ Version=F$GetSYI("VERSION") ! See what VMS version we have here:
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
                ", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
        VMS_SHAR_DUMMY.DUMMY
f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File");Set(Output_File,b,o);
Position(Beginning_of(b));Loop x:=Erase_Character(1);Loop ExitIf x<>"V";
Move_Vertical(1);x:=Erase_Character(1);Append_Line;
Move_Horizontal(-Current_Offset);EndLoop;Move_Vertical(1);
ExitIf Mark(None)=End_of(b) EndLoop;Position(Beginning_of(b));Loop
x:=Search("`",Forward,Exact);ExitIf x=0;Position(x);Erase_Character(1);
If Current_Character='`' then Move_Horizontal(1);else
Copy_Text(ASCII(INT(Erase_Character(3))));EndIf;EndLoop;Exit;
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="SENSE_TYPE_AHEAD.FOR"
$ Check_Sum_is=2099755065
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X`009Options /Extend_Source
X`009Integer Function Sense_Type_Ahead(First)
X`009Implicit NONE
X
XC** Sense Type-Ahead-Buffer from SYS$COMMAND`009`009       Michael Bednarek
X
X`009Integer Status,Func,Channel,SYS$Assign,SYS$QIOW,SYS$DASSGN
X`009Character First
X`009Include   '($IODEF)/List'
X`009Parameter (Func=IO$_SenseMode.or.IO$M_TypeAhdCnt)
X
X`009Structure /Sense_Mode_Buffer/
X`009 Integer*2 Number
X`009 Character First
X`009 Byte`009   %FILL(5)
X`009End Structure
X`009Record /Sense_Mode_Buffer/ P1
X
XC** assign a channel to the terminal
X`009Status=SYS$Assign('SYS$COMMAND',Channel,,)
X`009If (.not.Status) Call LIB$Signal(%VAL(Status))
X
XC** Sense Type-Ahead-Buffer
X`009Status=SYS$QIOW(,%VAL(Channel),
X`0091`009%VAL(Func),,,,
X`0091`009P1,%VAL(8),,,,)
X`009If (.not.Status) Call LIB$Signal(%VAL(Status))
X
X`009Sense_Type_Ahead=P1.Number
X`009First=P1.First
X
Xc** deassign the i/o channel
X`009Status=SYS$DASSGN(%VAL(Channel))
X`009If (.not.Status) Call LIB$Signal(%VAL(Status))
X
X`009Return
X`009End
$ GoSub Convert_File
$ File_is="INKEY0.FOR"
$ Check_Sum_is=1614178270
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X`009Options /Extend_Source
X`009Integer Function INKEY0 (c)
VC** Read one character without echo from SYS$COMMAND`009       Michael Bednare
Xk
XC   with a time-out value of zero
X
XC Usage: Status=INKEY0(c)
XC Returns character in ``c', and QIOW's Status. If no character was read,
XC Status is set to zero and ``c' remains unchanged.
X
XC Note: If function or arrow keys are pressed, each character of the
XC`009transmitted code is returned in successive calls.
XC`009E.g. pressing UP-ARROW will send the three characters ``<ESC>[A'.
X
X`009Implicit`009NONE
X`009Integer`009`009Func,Status,Channel,SYS$Assign,SYS$QIOW,SYS$DASSGN
X`009Character`009c
X
X`009Include   '($SSDEF)/List'
X`009Include   '($IODEF)/List'
X`009Parameter (Func=IO$_READVBLK.or.IO$M_NOECHO
X`0091`009    .or.IO$M_NOFILTR.or.IO$M_TIMED)
X
X`009Structure /IOSB/
X`009 Integer*2 Value
X`009 Integer*2 Count
X`009 Integer*4 Dev_Spec
X`009End Structure
X`009Record /IOSB/ IOSB
X
XC** assign a channel to the terminal
X`009Status=SYS$Assign('SYS$COMMAND',Channel,,)
X`009If (.not.Status) Call LIB$Signal(%VAL(Status))
X
XC** read 1 character
X`009Status=SYS$QIOW(,%VAL(Channel),%VAL(Func),IOSB,,,
X`0092`009%REF(c),%VAL(1),%VAL(0),,,)
X`009If (.not.Status) Call LIB$Signal(%VAL(Status))
X`009If (IOSB.Value.eq.SS$_TIMEOUT) then
X`009 INKEY0=0
X`009else
X`009 INKEY0=Status
X`009End If
X
Xc** deassign the i/o channel
X`009Status=SYS$DASSGN(%VAL(Channel))
X`009If (.not.Status) Call LIB$Signal(%VAL(Status))
X
X`009Return
X`009End
$ GoSub Convert_File
$ File_is="TINKEY0.FOR"
$ Check_Sum_is=1880651033
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X`009Options /Extend_Source
X`009Program TInkey0
X
X! Demonstrate usage of ``Sense_Type_Ahead' and 'Inkey0':
X
X`009Implicit`009Integer (A-z)
X`009Character`009c
X
X`009Do while (1)
X`009 l=Sense_Type_Ahead(c)
X`009 If (l.gt.0) then
X`009  Write`009(*,*) 'Sensed',l,' characters. First: >',c,'<',ICHAR(c)
X`009  Do i=1,l
X`009   Status=Inkey0(c)
X`009   If (Status.ne.0) Write (*,*) 'INKEY0 returns >',c,'<',ICHAR(c)
X`009  End Do
X`009 End If
X`009End Do
X
X`009End
$ GoSub Convert_File
$ Exit

arubin@spies.UUCP (Andy Rubin) (02/03/88)

In article <161@amelia.nas.nasa.gov>, woo@amelia.nas.nasa.gov (Alex Woo) writes:
> 
> Can someone send me a VMS routine (preferably PASCAL) which
> acts like the BASIC routine INKEY?  I just want to know if
> a key as been depressed, and what character or arrow or
> function key?
> 
> Alex Woo
> 
> P.S.  Don't blame me for this, I'm asking for a friend.

You could use the SMG routines, particularly, after you've defined
the window, and pasted it, you could use:

SMG$Read_KeyStroke ( KB_ID, ASCII_KEY_VALUE )

on a DEC terminal, UP == 274, DOWN == 275, LEFT == 276, RIGHT == 277
SELECT == 314, DO == 296, HELP == 295, PREV == 315, NEXT == 316
REMOVE == 313, FIND == 311

If you need more info on setting up a pasteboard and virtual display, then
let me know - I'll respond via mail so as not to clutter up this group...

                                        - Andy

-- 
Spies in the Wire PUBLIC ACCESS UNIX  |  {allegra|ames|cmcl2|ihnp4|linus|uunet|
Mount Kisco, New York                 |     rutgers|gatech|mcnc|cbosgd|sdcsvax|
                                      |            decvax}!philabs!spies!arubin
(914) 666-3997 300/1200 8N1           |                     <arubin@spies.UUCP>