At 10:49 2014-09-22, Ken Dibble <[email protected]> wrote:

This level's attribution lost:

What's the problem with making a loader program for your app that:

1. More work than creating a shortcut, presumably.

Actually, it is a fairly simple program. Mine simply works. It has gone over nine years without a change. I do not think that I have ever had to modify it. The code follows. I think that you can figure out the bits that you need to change.

     The include file cbs2.h contains only one thing that this program needs:
          #define CHRCR chr(13)

***** 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 *****

Set your short-cut to run cbs2load (however you rename it) rather than your app.

2. This software is also used by other organizations not on my LAN. In that case, I don't need and can't use a simple shortcut, but having one doesn't cause a problem. Having a loader program, on the other hand, creates a significant program as to where should the update be and how should it be retrieved.

No, it just needs to be decided and implemented. Once this is done, just stick the new version in the repository directory. The next time the app is started (actually the loader program), the app will be updated locally.

A loader is a solution to a different problem, and a more complex one than I need.

A loader is a simple program. Updating tables could be done in a similar manner.

[snip]

Sincerely,

Gene Wirchenko


_______________________________________________
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/
** 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.

Reply via email to