;  7 aug 85 esj created
;--------------------------< nextfile >---------------------------------
   E'F
   E'O NEXTFILE.( FILEDESC, FNAME)
;-----------------------------------------------------------------------
; purpose
;  to get the next file name from the file specified in fd
;
; input
   I'R FILEDESC(*)   ; descriptor of the file containing names
;
; output
   I'R FNAME(*)      ; cgos format filename. fname will = 0 when there
                     ; are no more files to be opened
;
; insert files
/INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
;
; local static storage
   I'R CHAR
;
; global
;  none
;
;----------------------< start of code >--------------------------------
   FNAME(0) = 0
   R'T
      E'E DGETCH.(CHAR, FILEDESC)
      W'R CHAR .E. '0D' .OR. CHAR .E. -1
         E'E PACKLINE.($! $, FNAME)
         B'K
      E'L
      E'E PACKLINE.(CHAR,FNAME)
   F'R

#  E'E TYPE.(0,0)
#  E'E HEXDMP.(FNAME, FNAME+FNAME+1, FNAME, FNAME)

   W'R CHAR .E. -1
      E'E CLOSTEXT.(FILEDESC)
      FNAME = 0
   E'L

   F'N  GOOD
   E'N
