.PROC,COLTEXT*I,
LFN "- Local File Name"                = (*F),
PFN "- Permanent File Name"            = (*N=,*F),
UN "- User Name of permanent file"     = (*N=,*F),
L "- Library receiving collected file" = (*N=#FILE,*F),
V "- Verify conversion (YES or NO)"    = (*N=NO,YES,NO),
.
.HELP
 The COLTEXT procedure COLlects a file, converts it to a TEXT record,
 verifies the conversion (optional), and replaces the record to a library.
 Requires CATALOG binaries with GENCAT entry point.

 Parameter   Default   Description
   Name       Value

   lfn                 local file name by which the file is accessed
  [pfn]       lfn      permanent file name of the stored file
  [un]                 user name in which file resides
  [l]                  library file to which record is replaced
  [v]         no       verify the file conversion process

.HELP,LFN
 The LFN parameter selects the name by which the file is accessed.
.HELP,PFN
 The PFN parameter selects the name by which the file is stored.
 The default is the value specified for the LFN parameter.
.HELP,UN
 The UN parameter specifies the User Name location of the file.
 The default value is the User Name in which this procedure executes.
.HELP,L
 The L parameter names a library to which TEXT records are replaced.
 The default value is the file containing this procedure.
.HELP,V
 The V parameter value selects verification of the conversion process
 from a FILE to a TEXT record. YES or NO values can be selected.
 The default value is NO. (Verification requires the EXTRACT binaries.)
.ENDHELP
.IFE,$PFN$.EQ.$$,SETPFN.
  $REVERT,EX.COLTEXT,LFN,LFN,UN,L,V.
.ENDIF,SETPFN.
.IFE,($PFN$.EQ.$L$),ERROR.
  $REVERT. CANNOT COLLECT PFN ONTO ITSELF
.ELSE,ERROR.
  GETFILE,LFN,PFN,UN,READ.
  $IFE,FILE(LFN,.NOT.AS),NOTFOUND.
    $REVERT. FILE PFN NOT FOUND
  $ENDIF,NOTFOUND.
  $NOTE,YYYYCOL,NR.+PFN
  $REWIND,LFN.
  $COPYEI,LFN,YYYYCOL.
  $PACK,YYYYCOL.
  .IFE,$V$.EQ.$YES$,VERIFY.
    CRELIB,YYYYCOL,#L=YYYYLIB.
    EXPTEXT,T=LFN,#L=YYYYLIB,G=YYYYSCR.
    $VERIFY,YYYYSCR,LFN,A,R.
    $UNLOAD,YYYYCOL.
    GETLIB,ALL,#L=YYYYLIB,G=YYYYCOL.
    $PURGE,YYYYLIB/NA.
  .ENDIF,VERIFY.
  REPLIB,YYYYCOL,#L=L.
  $UNLOAD,YYYYLIB,YYYYSCR,YYYYCOL.
.ENDIF,ERROR.
$SKIP,NOERROR.
  $EXIT.
  $UNLOAD,YYYYLIB,YYYYSCR,YYYYCOL.
  $IFE,(EF.EQ.TIE).OR.(EF.EQ.TAE),TERMINATED.
    $EXIT. COLTEXT *TERMINATED*
  $ENDIF,TERMINATED.
  $REVERT,ABORT. COLLECT LFN --> L FAILED
$ENDIF,NOERROR.
.IFE,FILE(LFN,.NOT.AS),FILEPRM.
  .IFE,$UN$.EQ.$$,NOUSERNAME.
    $PURGE,PFN/NA.
  .ENDIF,NOUSERNAME.
.ENDIF,FILEPRM.
$UNLOAD,LFN.
$REVERT. COLLECTED LFN --> L
/EOR
