LOCAL MyAppPath
ON SHUTDOWN Do ProperShutDown
_screen.addproperty("ClientPath","")
_screen.addproperty("DataPath","")
if _vfp.startmode = 0 && running/debugging in VFP IDE
MyAppPath = "C:\MyApp\" && hardcoded path for development/debugging
SET DEFAULT TO (MyAppPath)
SET PATH TO "reports;progs;libs;data;images;forms;menus" && so application can find the necessary files/source code
_screen.ClientPath = MyAppPath
_screen.DataPath = MyAppPath + "Data\"
ELSE
MyAppPath = ADDBS(JUSTPATH(SYS(16,0)))
SET DEFAULT TO (MyAppPath)
SET PATH TO "images;reports" && only if you are distributing some of this stuff with the app
_screen.ClientPath = MyAppPath
_screen.DataPath = RetrieveDataPath() && retrieve path information from data.ini file
IF EMPTY(_screen.DataPath) && couldn't find the data path so just exit
DO ProperShutDown
ENDIF
ENDIF
**********************************
FUNCTION RetrieveDataPath()
**********************************
IF FILE(_SCREEN.ClientPath + "data.ini") && do we already have a data.ini file that we can use and read from
lcDataPath = FILETOSTR(_SCREEN.ClientPath + "data.ini")
IF !DIRECTORY(lcDataPath)
lcDatapath = ADDBS(GETDIR("C:\","Locate Data Directory"))
IF EMPTY(lcDatapath)
MESSAGEBOX("Unable to locate required data. Contact your systems administrator.",64,"DATABASE NOT FOUND")
ELSE
=STRTOFILE(lcDatapath,_SCREEN.ClientPath + "data.ini")
ENDIF
ENDIF
ELSE && no data.ini file so let's create it
lcDatapath = ADDBS(GETDIR("C:\","Locate Data Directory"))
IF EMPTY(lcDatapath)
MESSAGEBOX("Unable to locate required data. Contact your systems administrator.",64,"DATABASE NOT FOUND")
ELSE
= STRTOFILE(lcDatapath,_SCREEN.ClientPath + "data.ini")
ENDIF
ENDIF
RETURN lcDataPath
ENDFUNC && RetrieveDataPath
**********************************
PROCEDURE ProperShutDown
**********************************
ON SHUTDOWN
CLEAR ALL
CLOSE ALL
IF _vfp.StartMode = 0
CANCEL
ELSE
QUIT
ENDIF
ENDPROC && ProperShutDown