Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An Application starter (with auto copy from server into local station).

Installation

An Application starter (with auto copy from server into local station).

by  ramani  Posted    (Edited  )
*********************************************************
** Author : Ramani (Subramanian.G)
** FoxAcc Software / Winners Software
** ramani_g@yahoo.com
** www.winnersoft.coolfreepages.com
** Type : Freeware with reservation to Copyrights
** Warranty : Nothing implied or explicit
*********************************************************
** How to Run..
*
* 1. Copy the application code as given below in a gsStart.Prg
* 2. Create a new project called gsStart
* 3. Add the gsStart.Prg as your only PRG to be added and set this as your main.Prg for this project.
* 4. Compile it into an executable.
* 5. Now you can use it to call your other VFP application. Set the application path, the first time you run the application, by navigating to the server location and selecting the application to run. Next time onwards, no questions will be asked. If ever you change the server location, make sure you delete the gsStart.MEM file in the user directory to make the gsStarter ask the question of application again.
[color green]
* 6. The benefit.. each user can have the updated version of your version auto copied when you copy your application into server. All you have to do when you make newer EXE is just copy it in the server even if users are already working. When they log in next time, they will auto start in the newer EXE without any act from your side.[color red]
* 7. Caution.. Make in your application.. path statement suitably for working on your server data files.
* 8. Note PUBLIC gcHomeDirectory, gcAppName, gcAppPath
* These can be used in your called application or can be ignored, in which case you can make them local as well.[color blue]
*********************************************************
** Project : APPLICATION starter. **
** PROG NAME: gsStart.PRG **
*********************************************************
*********************************************************
** Make sure only one instance started.
=myInstance("gsStart")
*********************************************************
** Set the initial environment values
DO set_environment
*********************************************************
ON ERROR DO errhand WITH ;
ERROR( ), MESSAGE( ), MESSAGE(1), PROGRAM( ), LINENO(1)
*********************************************************
** Set the default directory as this directory.
PUBLIC gcHomeDirectory, gcAppName, gcAppPath
LOCAL lcName, lnCopy, lnSource, llDoCopy

gcHomeDirectory = JUSTPATH(SYS(16,0))
SET DEFAULT TO (gcHomeDirectory)

*********************************************************
** IF application not set .. then select the Application
** gsStart.MEM stores the Application name along with fill Path
IF ! FILE("gsStart.MEM")
gcAppName = GETFILE("EXE,APP","","",0,"Select Application")
IF EMPTY(gcAppName)
QUIT
ENDIF
SAVE TO gsStart ALL LIKE gcAppName
ENDIF
RESTORE FROM gsStart ADDITIVE

** If application not yet set, QUIT
IF EMPTY(gcAppName)
=MESSAGEBOX("Source Application files not set. ")" ;
+CHR(13)+"Contact system administrator", ;
0+16,"Application not available")
QUIT
ENDIF

** find the application path and find the application
gcAppPath = ADDBS(JUSTPATH(gcAppName))
lcName = JUSTFNAME(gcAppName)
lnCopy =ADIR(aApp1,lcName) && DEFAULT DIRECTORY
lnSource =ADIR(aApp2,gcAppName) && SOURCE DIRECTORY

** If source directory not available, QUIT
IF lnSource = 0
=MESSAGEBOX("Source Application files not available." ;
+CHR(13)+"Contact system administrator", ;
0+16,"Application not available")
QUIT
ENDIF
*********************************************************
** If newer version available, copy it from source
llDoCopy = .f.
IF lnCopy = 0
llDoCopy = .t.
ELSE
IF aApp2(1,3) # aApp1(1,3) OR aApp2(1,4) # aApp1(1,4)
llDoCopy = .t.
ENDIF
ENDIF
IF llDoCopy
WAIT WINDOW "Copying a newer version of the application... please wait" NOWAIT NOCLEAR
COPY FILE &gcAppName TO &lcName
WAIT CLEAR
ENDIF
*********************************************************
** To avoid new users from starting application *
IF FILE(gcAppPath+"DoShut.txt")
_screen.Visible = .f.
=MESSAGEBOX("System maintenance in progress"+CHR(13) ;
+ "Try after some time",0+16, ;
"Application cannot start !")
QUIT
ENDIF
*********************************************************
** Call the Application
DO (lcName)
RETURN
*********************************************************
*********************************************************
** COMMON PROCEDURES & FUNCTIONS
*********************************************************
** My default environment settings
PROCEDURE set_environment
SET ANSI ON
SET CENTURY ON
SET CONFIRM ON
SET CURRENCY TO "Dhs "
SET DATE BRITISH
SET DELETED ON
SET EXACT OFF
SET EXCLUSIVE OFF
SET MESSAGE TO
SET MULTILOCKS ON
SET NEAR ON
SET NOTIFY OFF
SET REPROCESS TO AUTOMATIC
SET SAFETY OFF
SET STATUS BAR OFF
SET SYSMENU OFF
SET TALK OFF
** SET ENGINEBEHAVIOR 70 && VFP8 only
ENDPROC
*********************************************************
** My error handler
PROCEDURE errhand
PARAMETER merror, mess1, mess2, mprog, mlineno
LOCAL myMessage
myMessage='Error number: ' + LTRIM(STR(merror)) ;
+ CHR(13) + 'Error message: ' + mess1 + CHR(13) ;
+ 'Line of code with error: ' + mess2 + CHR(13) ;
+ 'Line number of error: ' + LTRIM(STR(mlineno)) ;
+ CHR(13) + 'Program with error: ' + mprog
=MESSAGEBOX(myMessage,"ERROR !!!",16)
RETURN
*********************************************************
** Procedure to allow only one instance of this application
PROCEDURE myInstance
** How run =myInstance("A name for your Application")
PARAMETERS myApp
=ddesetoption("SAFETY",.F.)
ichannel = DDEINITIATE(myapp,"ZOOM")
IF ichannel =>0
=DDETERMINATE(ichannel)
QUIT
ENDIF
=DDESETSERVICE(myapp,"define")
=DDESETSERVICE(myapp,"execute")
=DDESETTOPIC(myapp,"","ddezoom")
RETURN
*********************************************************
PROCEDURE ddezoom
PARAMETER ichannel,saction,sitem,sdata,sformat,istatus
ZOOM WINDOW SCREEN MAX
RETURN
*********************************************************
** EOF
*********************************************************
[color black]
To recap some of the points..

1. Make a gsStart.EXE distribution set. By including the VFP runtime files with the gsStart.EXE and making a installation set, makes the users installations very simple.

2. Since the code is very limited, you wont be revising this often as you may do with your application. That makes the working very easy.

3. This helps reduce the network trafic, by having the starter in each users local computer. The gsStarter will copy your pointed application to the local computer and start it every time auto synchronizing with server. SO any time you upgrade your application, simply copy it in the server and forget. The user will get distributed thru the gsStarter.EXE.

4. Make sure your application, sets the path to your server data location.. by adding suitable path statement..

Example..
gcDataPath = ADDBS(gcAppPath+"Data\")
gcOldPath = SET("PATH")
SET PATH TO gcAppPath+";"+gcDataPath+";"+gcOldPath
*********************************************************
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top