home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************
- FUNCTION SYSVERSION (app_exe, app_dat)
- *****************************************************************
-
- * Compare date and time on a file to that stored in another file
-
- * Copyright(c) 1991 -- James Occhiogrosso
-
- * Caution: Since SYSVERSION is critical to application
- * integrity, it returns to DOS with an error message
- * on any error that prevents proper version updating.
-
- * App_exe is typically the application EXE file
- * App_dat is typically the version control file
-
- LOCAL dat_size := 0, new_vers := old_vers := ''
-
- IF PCOUNT() != 2
- * Critical error - return to DOS
- ?? CHR(7)
- ? 'SYSVERSION error. - Both parameters are required.'
- QUIT
- ENDIF
-
- * Check file extensions. If not passed, use defaults.
-
- IF AT(".", app_exe) = 0
- * Assume first file is application EXE file
- app_exe = TRIM(app_exe) + '.EXE'
- ENDIF
-
- IF AT(".", app_dat) = 0
- * Assume second file is a DAT file
- app_dat = TRIM(app_dat) + '.DAT'
- ENDIF
-
- * Verify existence of application file
-
- IF .NOT. FILE(app_exe)
- * Critical error - return to DOS
- ?? CHR(7)
- ? 'SYSVERSION error. -- Incorrect DOS file name passed. - ' ;
- + UPPER(app_exe)
-
- QUIT
- ENDIF
-
- * Check control file size. Allow 15 bytes (the correct length)
- * or -1 (file does not exist). This prevents accidentally
- * overwriting an important file if the version control file
- * name is passed incorrectly.
-
- dat_size = FILESIZE(app_dat)
- IF dat_size = 15 .OR. dat_size = -1
-
- * Size of control file is correct or file does not exist
-
- * Read and format DOS date and time from first file
- new_vers = DTOS(FILEDATE(app_exe)) + ;
- STRTRAN(FILETIME(app_exe),':')
-
- * Read version control file's date/time string
- old_vers = MEMOREAD(app_dat)
-
- * If new version, update version control file
- * Compare new version string to old version string
- IF EMPTY(old_vers) .OR. new_vers > old_vers
- * New version. Update version control file
- MEMOWRIT(app_dat, new_vers)
- RETURN(.F.)
- ELSE
- * Otherwise, version strings match
- RETURN(.T.)
- ENDIF
-
- ELSE
- * Size of control file is incorrect. Do not rewrite it.
- * Programmer probably specified wrong name.
- ?? CHR(7)
- ? 'SYSVERSION error. - Control file ' + UPPER(app_dat) + ;
- ' - incorrect size'
- QUIT
- ENDIF
-
-
-