home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Demo / PCDUO / data1.cab / Script_Samples / FCOMPARE.scp < prev    next >
Encoding:
Text File  |  2003-11-28  |  2.0 KB  |  56 lines

  1. // FCOMPARE.SCP - Sample Script which compares file attributes.
  2. // Copyright (c) 2001-2002, Vector Networks Limited.
  3. // All Rights Reserved
  4. //
  5. // Revision History:
  6. // 7.0 20-Mar-02 DB  - Separated from GRPFLUPD.SCP.
  7.  
  8. // This function compares two files to check for differences. If the files have the same
  9. // size, date, and time, the function returns 0. If one of these is different from
  10. // the other file, a number between 1 and 4 is returned, depending on the value that is
  11. // different. If one or both of the files don't exist, 5 is returned.
  12.  
  13. Function FileCompare (File1 as String, File2 as String) as Integer
  14.     Dim a as Integer, b as Integer
  15.     Dim c as String, d as String
  16.  
  17.     Print "Comparing files : ", File1, " and ", File2
  18.  
  19.     FileCompare = 0
  20.  
  21.     If FileExists (File1) and FileExists (File2) Then
  22.         a = GetFileInfo (File1, FI_SIZE)
  23.         b = GetFileInfo (File2, FI_SIZE)
  24.         If (a = b) Then
  25.             a = GetFileInfo (File1, FI_DATE)
  26.             b = GetFileInfo (File2, FI_DATE)
  27.             If (a = b) Then
  28.                 a = GetFileInfo (File1, FI_TIME)
  29.                 b = GetFileInfo (File2, FI_TIME)
  30.                 If (a = b) Then
  31.                     c = GetFileInfo (File1, FI_ATTRIB)
  32.                     d = GetFileInfo (File2, FI_ATTRIB)
  33.                     If (c = d) Then 
  34.                         Print "The files are the same."
  35.                     Else
  36.                         Print "The file attributes are different"
  37.                         FileCompare = 1
  38.                     Endif
  39.                 Else
  40.                     Print "The files have different time stamps."
  41.                     FileCompare = 2
  42.                 Endif
  43.             Else
  44.                 Print "The files have different dates"
  45.                 FileCompare = 3
  46.             Endif
  47.         Else
  48.             Print "The files are different sizes."
  49.             FileCompare = 4
  50.         Endif
  51.     Else
  52.         Print "One (or both) of the files does not exist."
  53.         FileCompare = 5
  54.     Endif
  55. End Function
  56.