'**** HEADER ************************************************************
'EXDOS04.PF3 (release .02)
'Copyright (c) 1990-1991 Applied Resource Technologies, Inc.
'P.O. Box 64381, Dallas, Texas 75206 U.S.A. (214) 855-0449
'Description: Demonstrates filedatime()
'**** FUNCTION DECLARATIONS *********************************************
'library
external filedatime() progress() progtag()
'core
'**** VARIABLE DECLARATIONS *********************************************
'library
public ptstr psa
'core
'**** CODE **************************************************************

MAIN

local orig          ' store name of original file
local arch          ' store name of backup file
local orig_dtg      ' "date & time" string for original file
local orig_dtv      ' calculated datevalue+timevalue for original file
local arch_dtg      ' "date & time" string for backup file
local arch_dtv      ' calculated datevalue+timevalue for backup file
local err_msg       ' user error message

load "\smartii\poptools\lib\doslib.psl" in-memory
load "\smartii\poptools\lib\displib.psl" in-memory

orig = "\smartii\poptools\data\example.txt"
arch = "\smartii\poptools\data\example.bak"
err_msg = NULL

if filedatime(orig) < 0
     progress(fgerror,bgerror,"ERROR!",0)
     err_msg = orig & "not found!"
     jump err_exit
end if

'convert the original "date & time" to SmartWare II "now" type integer
orig_dtv = datevalue(group(ptstr,1))+timevalue(group(ptstr,2))
orig_dtg = ptstr  ' store the "date time" group
if filedatime(arch) < 0
     message "no backup... will backup"&orig&"at this time"
     jump done
end if

arch_dtg = ptstr  'store the archive "date time" group
'convert the archive "date & time" to SmartWare II "now" type integer
arch_dtv = datevalue(group(ptstr,1))+timevalue(group(ptstr,2))
if orig_dtv > arch_dtv
     progress(fgstandard,bgstandard, \
             "original:"&orig_dtg&"> backup:"&arch_dtg,1)
     progtag(fginvpleasing,bginvpleasing,"BACKUP")
     message orig & "- should be backed up"
elseif arch_dtv = arch_dtv
     progress(fgstandard,bgstandard, \
             "original:"&orig_dtg&"= backup:"&arch_dtg,1)
     progtag(fginvpleasing,bginvpleasing,"CURRENT")
     message orig & "- backup is current"
else
     progress(fgstandard,bgstandard, \
             "original:"&orig_dtg&"< backup:"&arch_dtg,1)
     progtag(fginvpleasing,bginvpleasing,"OLD VERSION")
     message "backup is more current than:" & orig
end if

jump done
label err_exit
     beep
     message err_msg
     screen shortrestore psa

label done
unload "doslib.psl"
unload "displib.psl"

END MAIN

