HP3000-L Archives

October 2002, Week 5

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Atwood, Tim (DVM)" <[log in to unmask]>
Reply To:
Atwood, Tim (DVM)
Date:
Tue, 29 Oct 2002 11:55:23 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (209 lines)
I do not know if this is exactly elegant. And it is probably way too
complicated for what you need. Sorry I don't have time to clean it up.

It is the MPEX use file we run to purge old versions of program source. It
is determining the versions to keep based on the current version letter. It
keeps just the current version and one version before. Purges anything older
than these two versions. So it is essentially doing what you need. But with
a bunch of prompts and other code you probably don't need.

I have left in all the prompts because you may wonder where the heck the
variables in the actual purge code came from. But to see the real meat of
the script, skip down to the section "This is the meat of the script"

%ECHO     Purge oldest versions of files from group .OLDSRC.
%ECHO     The least old version is kept in .OLDSRC.
%ECHO     Files are of the format 'pp####vt' where:
%ECHO        pp   = Two (or one) letter prefix
%ECHO        #### = Four digit module number
%ECHO        v    = Version - one letter (may be non-existent (null))
%ECHO        t    = Type - one letter file type
%ECHO     The least old version is the one with a 'v' letter one letter
%ECHO     up from the .srcipm version.  All other versions are purged.
%ECHO
:
%SETVAR x
%DELETEVAR x@
%SETVAR xoldsrcerror = 0
%SETVAR xlinefeed = CHR(10)
:
%ECHO     Are you sure you really want to do this?
%ECHO     Has backup of .OLDSRC been done?
%ECHO
%INPUT xtemp1;PROMPT="Continue? (N/Y):"
%SETVAR xtemp1 = UPS(xtemp1[0:1])
%IF xtemp1 <> "Y"
%    ECHO OLDPURGE Terminated
%    RETURN
%ENDIF
:
%INPUT xprefixes;PROMPT=&
       "What 'pp' prefixes? (?? for all) (cr=exit):"
%IF xprefixes = ""
%    RETURN
%ELSE
%    ECHO !xprefixes
%ENDIF
%SETVAR xprefixidx = 0
%SETVAR xprefixwork = UPS("!xprefixes")
%WHILE xprefixwork <> ""
%    SETVAR xprefixidx = xprefixidx + 1
%    SETVAR xprefix!xprefixidx = TOKEN("!xprefixwork",",")
%    SETVAR xprefixwork = REMTOKEN("!xprefixwork",",")
%    IF BETWEEN(LEN(xprefix!xprefixidx),1,2)
%    ELSE
%        SETVAR xoldsrcdisplay = xprefix!xprefixidx
%        ECHO !xoldsrcdisplay
%        ECHO ^ ERROR! Prefixes must be 1 or 2 chars separated by commas!
%        SETVAR xoldsrcerror = xoldsrcerror + 1
%    ENDIF
%ENDWHILE
%IF xprefixidx > 9
%    ECHO ERROR! Only nine prefixes may be specified!
%    RETURN
%ELSE
%    IF xoldsrcerror > 0
%        RETURN
%    ELSE
%        SETVAR xmaxprefix = !xprefixidx
%    ENDIF
%ENDIF
:
%INPUT xtypes;PROMPT=&
       "What 't' file types? (? for all) (cr=exit):"
%IF xtypes = ""
%    RETURN
%ELSE
%    ECHO !xtypes
%ENDIF
%SETVAR xtypeidx = 0
%SETVAR xtypework = UPS("!xtypes")
%WHILE xtypework <> ""
%    SETVAR xtypeidx = xtypeidx + 1
%    SETVAR xtype!xtypeidx = TOKEN("!xtypework",",")
%    SETVAR xtypework = REMTOKEN("!xtypework",",")
%    IF LEN(xtype!xtypeidx) = 1
%    ELSE
%        SETVAR xoldsrcdisplay = xtype!xtypeidx
%        ECHO !xoldsrcdisplay
%        ECHO ^ ERROR! Filetypes must be 1 character separated by commas!
%        SETVAR xoldsrcerror = xoldsrcerror + 1
%    ENDIF
%ENDWHILE
%IF xtypeidx > 9
%    ECHO ERROR! Only nine types may be specified!
%    RETURN
%ELSE
%    IF xoldsrcerror > 0
%        RETURN
%    ELSE
%        SETVAR xmaxtype = !xtypeidx
%    ENDIF
%ENDIF
:
<This is the meat of the script>
%ECHO
%ECHO **** Starting Purge of .OLDSRC
:
%SETVAR xtypeidx = 0
%WHILE xtypeidx < xmaxtype
%    SETVAR xtypeidx = xtypeidx + 1
:
%    SETVAR xprefixidx = 1
%    SETVAR xfileset = &
         xprefix!xprefixidx + "####@" + xtype!xtypeidx + ".OLDSRC"
%    WHILE xprefixidx < xmaxprefix
%        SETVAR xprefixidx = xprefixidx + 1
%        SETVAR xfileset = xfileset + "+" + &
             xprefix!xprefixidx + "####@" + xtype!xtypeidx + ".OLDSRC"
%    ENDWHILE
%    ECHO !xlinefeed
%    SHOWVAR xfileset
:
%    ECHO   Purged     Kept
%    ECHO   .OLDSRC    .OLDSRC
%    ECHO   --------   --------
%    SETVAR xcurrfile = " "
%    SETVAR xcurrtype = " "
%    SETVAR xcurrmodule = " "
%    SETVAR xcurrversion = " "
%    SETVAR xnextversion = " "
%    SETVAR xchecksrcipm = " "
%    REPEAT
:
%        SETVAR xlastchar = POS(".","!mpexcurrentfile") - 1
%        SETVAR xlength = xlastchar
%        SETVAR xi = xlength
%        SETVAR xcurrfile = mpexcurrentfile[0:xi]
%        SETVAR xj = xlastchar - 1
%        SETVAR xcurrtype = mpexcurrentfile[xj:1]
%        SETVAR xj = xlastchar - 2
%        IF BETWEEN(xcurrfile[xj:1],"0","9")
%            SETVAR xcurrversion = " "
%            SETVAR xi = xlength - 1
%            SETVAR xcurrmodule = xcurrfile[0:xi]
%        ELSE
%            SETVAR xj = xlastchar - 2
%            SETVAR xcurrversion = xcurrfile[xj:1]
%            SETVAR xi = xlength - 2
%            SETVAR xcurrmodule = xcurrfile[0:xi]
%        ENDIF
%        IF xcurrversion = "Z" OR xcurrversion = " "
%            SETVAR xnextversion = "A"
%        ELSE
%            SETVAR xnextversion = CHR(ORD(xcurrversion)+1)
%        ENDIF
%        SETVAR xchecksrcipm = &
             xcurrmodule + xnextversion + xcurrtype + ".SRCIPM"
:
%        IF FEXISTS("!xchecksrcipm")
%            ECHO              !xcurrfile
%        ELSE
%            ECHO   !xcurrfile
:            PURGE !xcurrfile.OLDSRC
%        ENDIF
:
%    FORFILES !xfileset
:
%ENDWHILE
:
%ECHO
%ECHO **** Completed Successfully

-----Original Message-----
From: Johnson, Tracy [mailto:[log in to unmask]]
Sent: Tuesday, October 29, 2002 8:38 AM
To: [log in to unmask]
Subject: [HP3000-L] Deleting All But The Last n Names in a Fileset


I'm looking for an elegant way to PURGE all
but the last 'n' files in a fileset?

FILE001  <---- want to purge this.
FILE002  <---- want to purge this.
FILE003  <---- want to purge this.
FILE010  <---- want to purge this.
FILEA00  <---- want to purge this.
FILEXYZ  <---- want to keep this.
FILEXZZ  <---- want to keep this.
FILEZZZ  <---- want to keep this.


I know I could read a LISTF into a file and
manipulate the filenames into a JOB stream
for PURGEing.  (It just doesn't seem elegant.)

MPEX is available.

BT
NNNN
Tracy Johnson
MSI Schaevitz Sensors

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2