[mod.computers.apollo] Apollo VT100 Emulator Example/Question

kevin%UUCP@YALE.ARPA@zeke.UUCP (03/09/87)

For some of our software, which also runs under VMS, we need to use the vt100
emulator on Apollo.  We need to determine the size of the vt100 window.  The
following code indicates a klugy way.  Does anybody know more about this?
What about the un-documented library of vte_$xxx functions?  See the code for
more complaints and questions.

If this code is useful to you, feel free.


C------------------------------------------------------------------------------
C                                               2 February 1987.  SMS.
      program ws
c
      integer* 4  ApolloWindowSize, SSStatus, X, Y
c
c      This program illustrates a way to obtain the size of an Apollo window,
c   whether it is a normal window or a VT100 emulator window.  It also
c   illustrates the use of the still undocumented STREAM_$ISAVT100 service.
c
c      It also illustrates a shortcoming in the IOS_$INQ_PATH_NAME service,
c   compared to the STREAM_$INQUIRE service which it supposedly replaces,
c   and the need for a way to get VT100 emulator window sizes without
c   requiring the use of the VSIZE command.
c
c   Run "ws" in a normal window and in a VT100 emulator window.
c
      SSStatus = ApolloWindowSize( X, Y)
c
      write (*, '(A, Z8.8, A, I4, A, I4)')
     1 '  Status = ', SSStatus, '   X =', X, '   Y =', Y
c
      end
C
C------------------------------------------------------------------------------
C                                               2 February 1987.  SMS.
      function ApolloWindowSize( X, Y)
c
%include '/sys/ins/base.ins.ftn'
%include '/sys/ins/ios.ins.ftn'
%include '/sys/ins/ms.ins.ftn'
%include '/sys/ins/pgm.ins.ftn'
%include '/sys/ins/streams.ins.ftn'
c
c   Declarations.
c
      integer* 4  ApolloWindowSize, X, Y
c
      logical  STREAM_$ISAVT100, VT100
c
      integer* 4  InquireErrorMask, InquireInputMask
c
      integer* 2  InquireAttributes( 162)
c
      integer* 2  StreamId
c
      equivalence (StreamId, InquireAttributes( 1))
c
      integer* 2  StreamNameLength
c
      equivalence (StreamNameLength, InquireAttributes( 2))
c
      character* 256  StreamName
c
      equivalence (StreamName, InquireAttributes( 35))
c
      integer* 4  MsPointer
c
      integer* 2  Vt100WindowSize( 2)
c
      character* (*)  VsizeCommand
c
      parameter (VsizeCommand = '/com/vsize')
c
      integer* 2  VsizeCommandLength
c
      parameter (VsizeCommandLength = len( VsizeCommand))
c
      integer* 4  VsizeProcessHandle
c
      integer* 2  VsizeStreamCount, VsizeStreamArray( 4)
c
      integer* 4  MbxFirstChar, MbxLastChar, SSStatus
c
      pointer / MsPointer / VT100WindowSize
c
      integer* 4  MsDesiredLength, MsReturnedLength, MsStart
c
      integer* 2  WindowList( 4), WindowListSize, WindowNr
c
c   Data.
c
      data InquireInputMask / STREAM_$IRM_NAME /
c
      data MsDesiredLength / 4 /
      data MsStart / 28 /
c
      data VsizeStreamCount / 4 /
      data VsizeStreamArray / STREAM_$STDIN
     1                      , STREAM_$STDOUT
     2                      , STREAM_$ERRIN
     3                      , STREAM_$ERROUT /

c
      data WindowListSize / 1 /
      data WindowNr / 1 /
c
c   Entry.
c
      StreamNameLength = -1
c
c   Get the stream id of "-STDOUT".
c
      inquire (unit = 6, strid = StreamId)
c!!
      write (*, *) ' StreamId =', StreamId
c
c   Determine whether or not window is a VT100 emulator window.
c
      VT100 = STREAM_$ISAVT100( StreamId, SSStatus)
c
      write (*, *) ' VT100:', VT100
c
c   Try to get the path name with the IOS service.
c
      call IOS_$INQ_PATH_NAME(
     1   StreamId
     2 , IOS_$ROOT_NAME
     3 , StreamName
     4 , StreamNameLength
     5 , SSStatus)
c!!
      write (*, '(A, Z8.8)') '  IOS status = ', SSStatus
c
c   Try to get the path name with the STREAM service.
c
      if (SSStatus .EQ. STATUS_$OK) then
         if (StreamNameLength .GT. 0) then
            write (*, *) ' >', StreamName( 1: StreamNameLength), '<'
         else
            write (*, *) ' StreamNameLength =', StreamNameLength
         end if
      end if
c
      call STREAM_$INQUIRE(
     1   InquireInputMask
     2 , STREAM_$USE_STRID
     3 , InquireAttributes
     4 , InquireErrorMask
     5 , SSStatus)
c!!
      write (*, '(A, Z8.8)') '  STREAM status = ', SSStatus
c
      if (SSStatus .EQ. STATUS_$OK) then
         if (StreamNameLength .GT. 0) then
            write (*, *) ' >', StreamName( 1: StreamNameLength), '<'
         else
            write (*, *) ' StreamNameLength =', StreamNameLength
         end if
      end if
c
      if (SSStatus .EQ. STATUS_$OK) then
c
c   Non-VT100 window.  Get window size with PAD service.
c
         if (StreamNameLength .LE. 0) then
c
            call PAD_$INQ_WINDOWS(
     1         StreamId
     2       , WindowList
     3       , WindowListSize
     4       , WindowNr
     5       , SSStatus)
c
            if (SSStatus .EQ. STATUS_$OK) then
c
               X = WindowList( 3)
               Y = WindowList( 4)
c
            end if
c
         else
c
c   VT100 window.  Run VSIZE to put window size into "VTE_CTL.xx" file.
c
            call PGM_$INVOKE(
     1         VsizeCommand
     2       , VsizeCommandLength
     3       , 0
     4       , 0
     5       , VsizeStreamCount
     6       , VsizeStreamArray
     7       , PGM_$WAIT
     8       , VsizeProcessHandle
     9       , SSStatus)
c
            if (SSStatus .EQ. STATUS_$OK) then
c
c   Construct "xxx.CTL.xxx" path name from "VTE_MBX.xx" path name.
c
               MbxFirstChar = index( StreamName, 'MBX')
c
               if (MbxFirstChar .GT. 0) then
c
                  MbxLastChar = MbxFirstChar+ 2
                  StreamName( MbxFirstChar: MbxLastChar) = 'CTL'
c
c   Access the critical part of the "VTE_CTL.xx" file.
c
                  MsPointer = MS_$MAPL(
     1               StreamName
     2             , StreamNameLength
     3             , MsStart
     4             , MsDesiredLength
     5             , MS_$COWRITERS
     6             , MS_$R
     7             , .false.
     8             , MsReturnedLength
     9             , SSStatus)
c
                  if (SSStatus .EQ. STATUS_$OK) then
c
                     X = Vt100WindowSize( 2)
                     Y = Vt100WindowSize( 1)
c
c   Release locks on the "VTE_CTL.xx" file.
c
                     call MS_$UNMAP(
     1                  MsPointer
     2                , MsReturnedLength
     3                , SSStatus)
c
                  end if
c
               else
c
                  SSStatus = -4
c
               end if
c
            end if
c
         end if
c
      end if
c
c   Return last status value.
c
      ApolloWindowSize = SSStatus
c
      return
      end




Kevin Buchs   3500 Zycad Dr. Oakdale, MN 55109  (612)779-5548
Zycad Corp.   {rutgers,ihnp4,amdahl,umn-cs}!meccts!zeke!kevin