! Making use of the 'connect count' on a file
! 
! Each time a file is 'connected' on EMAS (ie used) a count in the file
! descriptor is incremented, up to a max of 255.  This program provides
! two commands:  GIVE CCT and CLEAR CCT.
! 
! GIVE CCT(file) gives the current value of the connect count for your
! own file 'file'.  It doesn't have to connect the file to do this, so
! the count is not changed.
! 
! CLEAR CCT(file) clears the connect count for your own file 'file'.
!
!
!
externalintegerfnspec  DERROR(stringname  TXT)
externalintegerfnspec  DFINFO(string (31)FILE INDEX, FILE,
      integer  FSYS, ADR)
externalintegerfnspec  DFSTATUS(string (31)FILE INDEX, FILE,
      integer  FSYS, ACT, VALUE)
recordformat  DFF(integer  NKB, RUP, EEP, APF, USE, ARCH, FSYS, CONSEG, CCT,
   CODES,   byteinteger  SPARE, DAY , POOL , CODES2,
   integer  SSBYTE, string  (6) TRAN)
externalintegerfnspec  UINFI(integer  I)
externalstringfnspec  UINFS(integer  N)
!
!
!
EXTERNALROUTINE  GIVE CCT(STRING (255)FILE)
INTEGER  J
RECORD (DFF)R
STRING (255)TXT
      J = DFINFO(UINFS(1), FILE, UINFI(1), ADDR(R))
      -> OUT UNLESS  J = 0
!
      PRINTSTRING("Connect count on " . FILE . " is")
      WRITE(R_CCT, 1)
      RETURN 
OUT:
      J = DERROR(TXT)
      PRINTSTRING(TXT)
END 
!
!
!
EXTERNALROUTINE  CLEAR CCT(STRING (255)FILE)
INTEGER  J
STRING (255)TXT
      J = DFSTATUS(UINFS(1), FILE, UINFI(1), 9, 0)
      -> OUT UNLESS  J = 0
!
      PRINTSTRING("Connect count on ". FILE . " cleared")
      RETURN 
OUT:
      J = DERROR(TXT)
      PRINTSTRING(TXT)
END 
ENDOFFILE