     	FUNCTION IFQIOW( NCHS, DATA )
C
C  PROGRAMMER:  R.S. ZHOU
C		BOSTON COLLEGE, JANUARY, 1989
C
C	THIS ROUTINE PERFORMS A QIOW.
C
C	IFQIOW = ASCII VALUE OF THE 1ST TERMINATOR CHARACTER.
C	IF IFQIOW.EQ.13, DATA = INPUT STRING.
C	IF IFQIOW.NE.13, DATA = TERMINATOR STRING.
C	NCHS = SIZE OF DATA.
C
     	INCLUDE  '($IODEF)'
     	INTEGER*2 STAT(4)
     	CHARACTER TEXT*164, DATA*(*)

     	DATA = ' '
     	ICODE = IO$_READVBLK .OR. IO$M_ESCAPE
     	CALL SYS$ASSIGN( 'SYS$INPUT:', IC, , )
  111	TEXT = ' '
     	CALL SYS$QIOW( , %VAL(IC), %VAL(ICODE), STAT,,,
     +                   %REF(TEXT), %VAL(132),,,,,, )
C
C	STAT(1) = IO STATUS.
C	STAT(2) = OFFSET OF TERMINATOR STRING.
C	STAT(3) = FIRST TERMINATOR CHARACTER.
C	STAT(4) = SIZE OF TERMINATOR STRING.
C
     	IF( STAT(1).NE.1 ) GOTO 111	!IO ERROR
     	CALL SYS$DASSGN( %VAL(IC) )
     	IO = STAT(2)
     	IC = STAT(3)
     	IS = STAT(4)
     	IF( IC.NE.13 ) THEN
     	    IF(IS.GT.1) DATA=TEXT(IO+2:IO+IS)	!TERMINATOR STRING
     	    NCHS = IS-1
     	ELSE
     	    IF(IO.GT.0) DATA=TEXT(1:IO)		!INPUT STRING
     	    NCHS = IO
     	ENDIF
     	IFQIOW = IC
     	RETURN
     	END

     	SUBROUTINE IFQIOW_KEY( KEY )
C
C	THIS ROUTINE READS A SINGLE KEY STROKE.
C	ANSI KEYPAD ESCAPE SEQUENCES ARE RETURNED
C	WITH A SINGLE ASCII CODE OF THE LAST CHARACTERS.
C
     	INCLUDE  '($IODEF)'
     	INTEGER*2 STAT(4)
     	CHARACTER TEXT*16

     	TEXT = ' '
     	ICODE = IO$_READVBLK .OR. IO$M_ESCAPE .OR. IO$M_NOECHO
     	CALL SYS$ASSIGN( 'SYS$INPUT:', IC, , )
     	CALL SYS$QIOW( , %VAL(IC), %VAL(ICODE), STAT,,,
     +                   %REF(TEXT), %VAL(1),,,,,, )
C
C	STAT(1) = IO STATUS.
C	STAT(2) = OFFSET OF TERMINATOR STRING.
C	STAT(3) = FIRST TERMINATOR CHARACTER.
C	STAT(4) = SIZE OF TERMINATOR STRING.
C
     	IF( STAT(3).NE.0 ) THEN
     	    KEY = STAT(3)
     	ELSE IF( ICHAR(TEXT(1:1)).EQ.27 ) THEN
     	    TEXT = ' '
     	    CALL SYS$QIOW( , %VAL(IC), %VAL(ICODE), STAT,,,
     +                       %REF(TEXT), %VAL(2),,,,,, )
     	    KEY = ICHAR(TEXT(2:2))
     	ELSE
     	    KEY = ICHAR(TEXT(1:1))
     	ENDIF
     	CALL SYS$DASSGN( %VAL(IC) )
     	RETURN
     	END

