From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 13-JUL-1992 12:42:24.29
To:	jrw@psl.wisc.edu
CC:	info-vax@sri.com
Subj:	RE: Program to "rewind" file versions to ;1 ... the saga continues

OK, now you've intrigued me.  As a result, here's my version of REWIND.COM  To 
use it, say:

$ @rewind file.typ

It does assume that all versions of a file between the oldest and the newest do 
exist, but you can adapt it to allow for a sparse directory.

$! REWIND.COM
$ getp1:
$   if p1 .nes. "" then goto gotp1
$   read/prompt="_File: " sys$command p1
$   goto getp1
$!
$ gotp1:
$   highest = p1 + ";0"
$   lowest = p1 + ";-0"
$   highname = f$search( highest )
$   lowname = f$search( lowest )
$   highv = f$integer( f$parse( highname, , , "version" ) - ";" )
$   lowv = f$integer( f$parse( lowname, , , "version" ) - ";" )
$   nvers = highv - lowv + 1
$   newv = 1
$   oldv = lowv
$!
$ loop:
$   from = p1 + ";" + f$string( oldv )
$   to = p1 + ";" + f$string( newv )
$   rename 'from' 'to'
$   newv = newv + 1
$   oldv = oldv + 1
$   if oldv .le. highv then goto loop
$   write sys$output "%REWIND-I-ALLDONE, file ", p1, " rewound"


-----------------------------+--------------------------------
 Brian Tillman               | Internet: tillman@swdev.si.com
 Smiths Industries, Inc.     |
 4141 Eastern Ave. MS129     | Hey, I said this stuff myself.
 Grand Rapids, MI 49518-8727 | My company has no part in it.
-----------------------------+--------------------------------

