* Last processed by NICE on 12-Jun-2000 15:44:00
* Customized for :  IEEE, LINUX, UNIX, MOTIF, F77
      CALL GET_DOC('ps')
      END
*<FF>
      SUBROUTINE GET_DOC(TYPE)
      CHARACTER*(*) TYPE
      CHARACTER*132 FILE,FICH,LINE
      INTEGER MDOC,NDOC
      PARAMETER (MDOC=32)
      CHARACTER*16 DOCS(MDOC),LADOC
      INTEGER N,IDOC,LENC
      LOGICAL ERROR
*
      FICH = TYPE
      CALL SIC_PARSEF(FICH,FILE,'GAG_DOC:','.LIST')
      OPEN (UNIT=1,FILE=FILE(1:LENC(FILE)),STATUS='OLD')
      NDOC = 0
      DO WHILE(.TRUE.)
         READ(1,'(A)',END=10) LINE
         WRITE(6,100) LINE(1:LENC(LINE))
         IF (LINE(1:1).NE.' ') THEN
            NDOC = MIN(NDOC+1,MDOC)
            DOCS(NDOC) = LINE
            CALL SIC_UPPER(DOCS(NDOC))
         ENDIF
      ENDDO
10    CLOSE (UNIT=1)
*
      DO WHILE (.TRUE.)
         CALL GAGOUT('I-DOC,  Enter document name ')
         READ(5,'(A)') LINE
         N = LENC(LINE)
         IF (N.EQ.0) RETURN
         CALL SIC_UPPER(LINE)
         CALL SIC_AMBIGS('DOC',LINE,LADOC,IDOC,DOCS,NDOC,ERROR)
         IF (.NOT.ERROR) THEN
            IF (TYPE.EQ.'ps') THEN
               CALL SIC_PARSEF(LADOC,FILE,'GAG_DOC:','.PS')
               LINE = 'ghostview -a4 '//FILE(1:LENC(FILE))
            ELSE
               CALL SIC_PARSEF(LADOC,FILE,'GAG_DOC:','.DVI')
               LINE = 'xdvi '//FILE(1:LENC(FILE))
            ENDIF
C+VMS
c            CALL LIB$SPAWN('$ '//LINE(1:LENC(LINE)),,,0)
C-VMS
C+UNIX
            CALL SIC_LOWER (LINE(1:LENC(LINE)))
            CALL SYSTEM(LINE(1:LENC(LINE))//CHAR(0))
C-UNIX
         ENDIF
      ENDDO
C+VMS
c100   FORMAT(1X,A)
C-VMS
C+UNIX
100   FORMAT(A)
C-UNIX
      END
