Thank you Gene and Peter
The use of adir, as you suggested is very simple and effective.
I will develop a loader along those lines
And thank the others for your input as well
Rafael Copquin
El 15/09/2014 15:48, Gene Wirchenko escribió:
At 09:02 2014-09-15, Rafael Copquin <[email protected]> wrote:
I need to know the date and exe was compiled and placed in a network
drive, compare it with the exe date on the local drive and replace
the latter if the network version is newer.
How is this done?
The purpose is to be able to make changes to a working app, place the
newly compiled exe in a server folder and have each user local
machine compare the local exe to the server exe and use the newer
version
I wrote a small loader app to handle this. You will have to
adjust it for your settings.
The only thing used from the include file is CHRCR which is simply:
* New Line
#define CHRCR chr(13)
* Linefeed
#define CHRLF chr(10)
* Carriage Return - Linefeed
#define CHRCRLF CHRCR+CHRLF
***** Start of Included Code *****
* cbs2load
* Loader Program for CBS2
* Last Modification: 2005-07-21
* This program checks that the local copy of CBS2 is the latest
version
* as compared to a repository copy. If the local copy is not current,
it is
* replaced with a copy of the repository version. Either way,
assuming no
* errors, CBS2 is then started. The version checking is by file
datestamp.
*
* This program should be compiled to an executable. Use:
* build project cbs2load from cbs2load
* build exe cbs2load from cbs2load recompile
* Copy the executable to s:\cbs2\env.
#include "cbs2.h"
* Settings (assumes starting from default values)
set talk off
set exact on
* Do this in case a configuration file with screen=off has not been
set up
* yet. If there is no configuration file, there will be a flash of
the VFP
* main screen.
*
* Position to just off screen at the bottom, righthand corner.
_screen.top=sysmetric(2)
_screen.left=sysmetric(1)
_screen.visible=.f.
* Configuration Data
local progtitle, localprog, reposprog
progtitle="CBS2"
localprog="cbs2.exe" && local filename
reposprog="s:\cbs2\app\cbs2.exe" && repository filename
* Status Message and Flags
local statusmsg, haserror, haswarning
statusmsg=""
haserror=.f.
haswarning=.f.
* Whether to copy from the repository
local copyrepos
copyrepos=.f.
* Directory Data
local reposcnt, reposdata(1)
local localcnt, localdata(1)
* In each directory, there should be only one copy of the program. If
* there is more than one, then the directory is corrupt, since the
name
* does not contain wildcard characters.
reposcnt=adir(reposdata,reposprog)
if reposcnt>1
haserror=.t.
if statusmsg>""
statusmsg=statusmsg+CHRCR
endif
statusmsg=statusmsg+"Repository directory is corrupt."
endif
localcnt=adir(localdata,localprog)
if localcnt>1
haserror=.t.
if statusmsg>""
statusmsg=statusmsg+CHRCR
endif
statusmsg=statusmsg+"Local directory is corrupt."
endif
* If there is no repository copy, this is an error.
if reposcnt=0
haserror=.t.
if statusmsg>""
statusmsg=statusmsg+CHRCR
endif
statusmsg=statusmsg+;
"Repository version of "+progtitle+" does not exist."
endif
* If there is no local copy, this could just be a new Station.
if localcnt=0
haswarning=.t.
copyrepos=.t.
if statusmsg>""
statusmsg=statusmsg+CHRCR
endif
statusmsg=statusmsg+;
"Warning: Local version of "+progtitle+" does not exist."
endif
* One of each: how do the dates compare?
if reposcnt=1 and localcnt=1
do case
case reposdata(1,3)>localdata(1,3)
copyrepos=.t.
case reposdata(1,3)=localdata(1,3) and
reposdata(1,4)>localdata(1,4)
copyrepos=.t.
otherwise
copyrepos=.f.
endcase
endif
* Error exit
if haserror
statusmsg=statusmsg+CHRCR+CHRCR+;
progtitle+;
" can not be started. Please save this message for Technical Support."
wait statusmsg window nowait noclear
wait && Save message until keystroke or mouse click.
return
endif
* Set copy message.
if copyrepos
if statusmsg>""
statusmsg=statusmsg+CHRCR+CHRCR
endif
if localcnt>0
statusmsg=statusmsg+;
"An updated version of "+progtitle+;
" is being installed. It will then be started."
else
statusmsg=statusmsg+;
progtitle+" is being installed. It will then be started."
endif
endif
* Display non-error status message (if any).
if statusmsg>""
wait statusmsg window nowait noclear
endif
* Copy from repository.
if copyrepos
set safety off
copy file (reposprog) to (localprog)
endif
* Run whichever version. Do not wait for it to return.
run /n &localprog
return
***** End of Included Code *****
Sincerely,
Gene Wirchenko
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.