From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM" 12-JUN-1993 11:42:54.47
To:	EVERHART
CC:	
Subj:	Utility RF.COM - recursive file/DCL operations V1.3

X-Newsgroups: comp.os.vms
Subject: Utility RF.COM - recursive file/DCL operations V1.3
Message-Id: <KELLEY.93Jun8092816@corsica.progress.com>
From: kelley@corsica.progress.com (John Kelley)
Date: Tue, 8 Jun 1993 14:28:16 GMT
Sender: usenet@progress.com (Mr. Usenet)
Distribution: comp
Organization: Progress Software Corporation
Nntp-Posting-Host: corsica
Lines: 200
To: Info-VAX@kl.sri.com
X-Gateway-Source-Info: USENET

$!******************************************************************************
$!                      *** Use at your own risk ***
$!
$! Procedure     : RF.COM  Version: 1.3   
$!
$! Written by    : KELLEY
$!
$! Create Date   : Wednesday, March 31th, 1993  13:52:56.02 A.M.
$!
$! Usage	 : @rf target*.files command
$!                 @rf target*.files nowild command
$!                 @rf filea,fileb,filec command nfile
$!                 @rf filea,fileb,filec
$!                    $ open/read myfile nfile
$!                    $ read/end=ex myfile line
$!                    $ write sys$output line
$!                    $ ex:
$!                    $ close myfile
$!                    $ show time
$!                 @rf *.com
$!                    $ write sys$output f$edit(dqtqtnfiledqt,dqtUPCASEdqt)
$!
$!                 @rf *.com write sys$output f$edit(dqtqtnfiledqt,dqtUPCASEdqt)
$!                 rf *.com wr f$file_attr(dqtqtnfiledqt,"RFM")
$!                 rf *.x rename nfile qtf$element(0,dqt.dqt,nfile)qt.y/log
$!
$!                 @rf filea,fileb,filec command
$!
$!                 noninteractive: @rf target*.files command
$!                 noninteractive: @rf target*.files nowild command
$!                 noninteractive: @rf target*.files command nfile
$!                 noninteractive: @rf target*.files command nfile
$!
$!                 @rf l*.com in.tmp nowild
$!                 @rf l*.com in.tmp
$!                 
$!                 Example templates are available on request.
$!
$! Description	 : Allows for repeated execution of dcl commands
$!                 for a list of files.  The nowild option prevents
$!                 wildcard expansion even though you use wildcards.
$!                 Special variable NFILE allows usage of actual
$!                 file name resultant from wildcard search.
$!                 Last example shows a file in.tmp that contains
$!                 all commands that are to be executed, allowing
$!                 for templates to be collected for various
$!                 purposes.
$!
$!  Modify Date : Thursday, June 3rd 1993, 1:00:22.86 P.M.
$!   Comments   : Added debug logical "RFDEBUG".  When this logical is
$!                defined, rf.com will display the command it is trying
$!                to execute.  This will allow you to fiddle around with
$!                your syntax to get stuff to work.
$!
$!
$!  Modify Date : Friday, May 28th 1993, 3:17:47.59 P.M.
$!   Comments   : Added new syntax "qt" and "dqt" to allow insertion of
$!                single and double quotes.  Added myclose and myfile to
$!                allow for a tag to handle file reading with "/end=myclose".
$!                You must use myfile as the file descritptor, however.
$!                Note that "QT" and "DQT" MUST be uppercase if template
$!                file input is used.
$!
$!  Modify Date :
$!   Comments   :
$!
$!
$!
$!
$!******************************************************************************
$ on control_y then goto endit
$ num = 0
$ temp = ""
$ op1 = " "
$ qt = "'"
$ dqt = """
$ maxnum = 0
$ if p2 .nes. "NOWILD"
$    then
$    wild = 0
$    wopt = qt+"p1"+qt
$ else
$    wild = 1
$    wopt = qt+"p1"+qt
$    p2 = ""
$    if p3 .nes. "" then p2 = " "
$    maxnum = num
$ endif
$ if p1 .eqs. "" then goto CMDSLP
$ if f$search("''p2'") .nes. "" then goto CMDFOPN
$ if f$mode() .nes. "INTERACTIVE" then goto NONINTER
$ if p2 .nes. "" .and. p2 .nes. "NOWILD" then goto NONINTER
$ goto CMDSLP
$MVPRM:
$ fpos = f$locate("NFILE",f$edit(comnds'num',"UPCASE"))
$ comnds'num'=f$ext(0,fpos,comnds'num')+qt+"NFILE"+qt+f$ext(fpos+5,900,comnds'num')+"'"
$ return
$DQTS:
$ fpos = f$locate("DQT",f$edit(comnds'num',"UPCASE"))
$ comnds'num'=f$ext(0,fpos,comnds'num')+dqt+f$ext(fpos+3,900,comnds'num')+"'"
$ if f$locate("dqt",comnds'num') .lt. f$length(comnds'num') then goto DQTS
$ if f$locate("DQT",comnds'num') .lt. f$length(comnds'num') then goto DQTS
$ return
$SQTS:
$ fpos = f$locate("QT",f$edit(comnds'num',"UPCASE"))
$ comnds'num'=f$ext(0,fpos,comnds'num')+qt+f$ext(fpos+2,900,comnds'num')+"'"
$ if f$locate("qt",comnds'num') .lt. f$length(comnds'num') then goto SQTS
$ if f$locate("QT",comnds'num') .lt. f$length(comnds'num') then goto SQTS
$ return
$CMDFOPN:
$ if p3 .eqs. "NOWILD" then wild = 1
$ open/read cmdfile 'p2'
$CMDSFL:
$ num = num+1
$ read/end=ENDCMDS cmdfile comnds'num'
$ if f$locate("NFILE",comnds'num') .lt. f$length(comnds'num') then gosub MVPRM
$ if f$locate("nfile",comnds'num') .lt. f$length(comnds'num') then gosub MVPRM
$ if f$locate("DQT",comnds'num') .lt. f$length(comnds'num') then gosub DQTS
$ if f$locate("QT",comnds'num') .lt. f$length(comnds'num') then gosub SQTS
$ if f$length(comnds'num') .gt. 1 then goto CMDSFL
$ goto ENDCMDS
$CMDSLP:
$ num = num+1
$ INQUIRE/nopunc comnds'num' "$ "
$ if f$locate("NFILE",comnds'num') .lt. f$length(comnds'num') then gosub MVPRM
$ if f$locate("DQT",comnds'num') .lt. f$length(comnds'num') then gosub DQTS
$ if f$locate("QT",comnds'num') .lt. f$length(comnds'num') then gosub SQTS
$ if f$length(comnds'num') .gt. 1 then goto CMDSLP
$ goto  ENDCMDSB
$ENDCMDS:
$ close cmdfile
$ENDCMDSB:
$ maxnum = num
$ if p1 .eqs. "" then inquire p1 "Files"
$ if f$length(p1) .lt. 1 then goto endit
$PFILES:
$ if num .eq. 0 .and. wild .eq. 0 then num = 1
$ pval = ""
$ quote = """
$PLOOP:
$ if f$locate(",",p1) .eqs. f$length(p1) then goto INTER
$ if f$ext(0,1,P1) .eqs. quote then P1 = f$edit(f$ext(1,200,P1),"COMPRESS")
$ if f$length(P1) .lt. 1 then goto ENDIT
$ pval = p1
$LOOP:
$ p1 = f$element(0,",",pval)
$ pval = f$ext(1,2000,pval-p1)
$ if f$length(p1) .gt. 1 then goto INTER
$ goto ENDIT
$INTER:
$! if wild .eq. 0 then num = 0
$ if num .gt. maxnum  then goto endit
$ num = 0
$ nfile = wopt
$ if f$length(nfile) .eq. 0 then goto ENDIT
$DOLOOP:
$ gosub DCMDSLP
$ if (wild .eq. 1 .or. f$locate("*",p1) .eq. f$length(p1)) .and. f$length(pval) .gt. 0 then goto LOOP
$ if num .lt. maxnum then goto DOLOOP
$ if f$length(pval) .gt. 0 then goto LOOP
$ goto INTER
$DCMDSLP:
$ on error then goto endit
$ if op1 .eqs. p1 .and. wild .eq. 1 then goto endit
$ if op1 .eqs. p1 .and. f$locate("*",p1) .eq. f$length(p1) then goto endit
$ op1 = p1
$ num = num+1
$ if f$length(pval) .lt. 1 .and. -
  (maxnum .lt. num .or. maxnum .eq. num .or. num .eq. 0)
$ then
$    return
$ else
$    if maxnum .eq. 2 then num = 1
$ endif
$ xxx = comnds'num'
$ if wild .eq. 0 .and. (num .eq. 1 .or. num .eq. maxnum)
$    then
$    nfile = f$search("''p1'")
$    nfile = f$ext(0,f$length(f$element(0,";",nfile)),nfile)
$    if nfile .eqs. "" .and. f$length(pval) .eq. 0 then goto endit
$ if f$length(nfile).eq. 0 .and. f$length(pval) .gt. 0 .and. num+1 .eq. maxnum then goto LOOP
$ endif
$ if f$trnlnm("RFDEBUG") .nes. "" then write sys$output "EXEC:",xxx
$ 'xxx'
$ return
$MYCLOSE:
$ close myfile
$ num = maxnum
$ return
$NONINTER:
$ comnds1 = p2+" "+p3+" "+p4+" "+p5+" "+p6+" "+p7+" "+p8
$ maxnum = 2
$ num = 1
$ if f$locate("NFILE",comnds'num') .lt. f$length(comnds'num') then gosub MVPRM
$ if f$locate("DQT",comnds'num') .lt. f$length(comnds'num') then gosub DQTS
$ if f$locate("QT",comnds'num') .lt. f$length(comnds'num') then gosub SQTS
$ comnds2 = ""
$ goto PFILES
$ENDIT:
$ exit

