From:	CSBVAX::MRGATE!RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP  1-SEP-1988 21:30
To:	ARISIA::EVERHART
Subj:	Re: set term characteristics


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Thu,  1 SEP 88 11:28:40 PDT
Received: from MITVMA.MIT.EDU by KL.SRI.COM with TCP; Thu, 1 Sep 88 09:38:22 PDT
Received: from MITVMA.MIT.EDU by MITVMA.MIT.EDU (IBM VM SMTP R1.1) with BSMTP id 3411; Thu, 01 Sep 88 12:37:13 EDT
X-Delivery-Notice:  SMTP MAIL FROM does not correspond to sender.
Received: from MITBATES.BITNET (smtpuser) by MITVMA.MIT.EDU (Mailer X1.25) with
 BSMTP id 3410; Thu, 01 Sep 88 12:37:11 EDT
Date: Thu, 1 Sep 88 11:52 EDT
From: "Ernie Bisson ext.218 MIT-BATES" <BISSON%MITBATES.BITNET@MITVMA.MIT.EDU>
Subject: Re: set term characteristics
To: info-vax@kl.sri.com
X-VMS-To: IN%"info-vax@kl.sri.com"

>        I want to set terminal characteristics from within a
>    program (FORTRAN) without doing a spawn.  In particular I want
>    to toggle betwen type-ahead and    no type-ahead.  I think chapter 8
>    of the I/O User's Reference Manual (Part I) discusses how to
>    do this, however I am new to VMS systems routines and can not
>    fathom the discussion.   Any help on how to interpret this
>    information would be appreciated.  Needless to say, an example
>    would be extremely usefull.

The following FORTRAN program will set your terminal to no type-ahead. To
restore the original terminal characteristics before exiting your program
use the following call.

                CALL SET_TERM_CHARACTERISTICS(.TRUE.)


Ernest R. Bisson
M.I.T. Bates Linear Accelerator
P.O. Box 846
Middleton, Massachusetts  01949-2846
(617) 774-2370

Bitnet : BISSON@MITBATES


Heres, the program,

        integer*4 sys$assign, sys$dassgn
        integer*4 retstat, ichan

        common /io_channel/ichan

        retstat = sys$assign('tt', ichan, , )
        if (.not. retstat) call lib$signal(%val(retstat))
        call set_term_characteristics(.false.)

        retstat = sys$dassgn(%val(ichan))
        if (.not. retstat) call lib$signal(%val(retstat))

        end


        subroutine set_term_characteristics(restoring)

        external  io$_sensemode, io$_setmode
        external  tt$v_notypeahd

        logical   restoring

        integer*2 iostat(4)
        integer*4 sys$qiow, ttchar_buffer(2), save_ttchar_buffer
        integer*4 retstat, iofunc, ichan

        common /io_channel/ichan

c
c       THIS SUBROUTINE IS USED TO SET THE TERMINAL TO NO TYPE-AHEAD
c
c       THE ORIGINAL TERMINAL CHARACTERISTICS CAN BE RESTORED WITH THE
c       FOLLOWING :
c
c                   CALL SET_TERM_CHARACTERISTICS(.TRUE.)
c
c
        if ( restoring ) then
             ttchar_buffer(2) = save_ttchar_buffer

             iofunc = %loc(io$_setmode)

             retstat = sys$qiow(%val(1), %val(ichan), %val(iofunc),
     &                          iostat, , , ttchar_buffer, %val(8), , , , )
             if (.not. retstat) call lib$signal(%val(retstat))

        else
             iofunc = %loc(io$_sensemode)

             retstat = sys$qiow(%val(1), %val(ichan), %val(iofunc),
     &                          iostat, , ,ttchar_buffer ,%val(8) , , , , )
             if (.not. retstat) call lib$signal(%val(retstat))

             save_ttchar_buffer = ttchar_buffer(2)      ! Save terminal characte
risti
   cs to restore later

             ttchar_buffer(2) = ibset(ttchar_buffer(2),%loc(tt$v_notypeahd))
! S
   et no typeahead

             iofunc = %loc(io$_setmode)

             retstat = sys$qiow(%val(1), %val(ichan), %val(iofunc),
     &                          iostat,, , ttchar_buffer, %val(8), , , , )
             if (.not. retstat) call lib$signal(%val(retstat))

        end if

        return
        end



