07-22-2011, 12:29 PM
Hi All,
I have a local db file that I want to check against a network copy for any updates. I wrote this script (see below) to compare the time modified and used the DateTime function to help with numerical comparison. I am assuming that the larger number represents the more recent file. Will that always be true?
I could do more testing but thought I would post the code here and see if anyone knows more elegant way.
Thanks!!! S
Function UpdateDb
I have a local db file that I want to check against a network copy for any updates. I wrote this script (see below) to compare the time modified and used the DateTime function to help with numerical comparison. I am assuming that the larger number represents the more recent file. Will that always be true?
I could do more testing but thought I would post the code here and see if anyone knows more elegant way.
Thanks!!! S
Function UpdateDb
str- NetworkDbFile="\\NetworkLocation\AdminDB.db3"
str- LocalDbFile="$common documents$\AdminDB.db3"
if(!dir(LocalDbFile));;if local copy does not exist
,out "Copying AdminDb from network....."
,cop- NetworkDbFile LocalDbFile; err ErrMsg(1)
,out "Copying AdminDb.....done."
,
Dir d1
if d1.dir(NetworkDbFile 0) ;;if exists
,DATE dNetworkTimeMod=d1.TimeModified2
,
Dir d2
if d2.dir(LocalDbFile 0) ;;if exists
,DATE dLocalTimeMod=d2.TimeModified2
out NetworkTimeMod
out LocalTimeMod
DateTime dtNetworkTimeMod.FromDATE(dNetworkTimeMod)
DateTime dtLocalTimeMod.FromDATE(dLocalTimeMod)
out dtNetworkTimeMod
out dtLocalTimeMod
;
if dtNetworkTimeMod > dtLocalTimeMod
,cop- NetworkDbFile LocalDbFile; err ErrMsg(1)
,