!*! Updated on 03-Jun-94 at 3:53 PM by Michael A. Lewis; edit time: 0:28:05
!*! Created on 03-Jun-94 at 2:20 PM by Michael A. Lewis; edit time: 0:10:20
!
!       Compares files in directories
!       Copyright 1994 by d/SOFT Ltd
!       All Rights Reserved
!
!       Permission is given to use this program and modify it for your own
!       use. You may not distribute this program or non-trivial parts of it
!       without the express permission of d/SOFT Ltd, 310 Cedar Lane, Teaneck
!       NJ, 07666 (717) 629-7190.
!
!       This program compares the contents of the directory that you are
!       logged into with the directory specified on the command line. The
!       files are examined to see if the hash totals are the same.
!
string hash1,hash2                      ! two variables to hold hash values
string filename                         ! name of file to check
string 14 device,account,name
string 80 tail                          ! command tail
float i,j

       log.errors
       when len(.options)=0
               dual.print "%Usage: _run cmpdir {devn:}{[p,pn]}{/f:name}"
               end
       wend
       tail=ucs(.options)
       j=instr(1,tail,"/F:")
       when j
               filename=filespec(tail[j+3,len(tail)],"LST")
               when filename=""
                       print "%Bad list filename specified"
                       end
               wend
               tail=tail[1,j-1]
               open #99,filename,output
               j=99
               print #j,"Directory Comparison Report"
       wend
       i=instr(1,tail,":")
       if i device=tail[1,i]
       i=instr(1,tail,"[")
       if i account=tail[i,len(tail)]
       open #1,"[]",directory          ! open our directory
       do next.directory #1 into name until name=""
               filename=device+name+account
               print #j,"Checking ";name;". ";
               if j print ".";
               lookup filename,i
               when i=0
                       print #j,"Does not exist in ";device+account
                       again
               wend
               hash1=hash(name)
               hash2=hash(filename)
               when hash1<>hash2
                       print #j,"Hash does not match"
                       print #j,"                      ";hash1;"; ";hash2
               else
                       print #j,"Same."
               wend
       enddo
       print
       end