*********************************************************************** * PROCEDURE LAUNCH_RS.PRG *********************************************************************** * Purpose.....: Start execution of one or the other of two passed program * names. If no names are passed, use these default values: * MASSREAL directory: MASSONE.EXE, MASSNEW.EXE * MASSPLAY directory: MASSPLAY.EXE * Copy needed DLLs and other files to local directory on C:. * Parameters..: tcProgram1 Default: 'MASSONE.EXE' * tcProgram2 Default: 'MASSNEW.EXE' * tcLocalDirectory Default: 'C:\MASSONE\' * Examples....: (from DOS) LAUNCH_RS MASSONE.EXE MASSNEW.EXE "C:\MASSONE\" * (from PIF) MASSONE.EXE * (from PIF) MASSNEW.EXE * (from PIF) MASSTEST.EXE * Notes.......: VFP COPY FILE command below cannot copy an open file. * * If the this program is named MASSONE.EXE, it will copy program * MASXONE.EXE to the local directory and execute it there. If it * can't find MASXONE.EXE, it will try to copy MASXNEW.EXE to the * local directory and execute it. * * If the this program is named MASSNEW.EXE, it will copy program * MASXNEW.EXE to the local directory and execute it there. If it * can't find MASXNEW.EXE, it will try to copy MASXONE.EXE to the * local directory and execute it. * * In general, if named MASSNAME.EXE it will launch MASXNAME.EXE. * Calls.......: * Refers to...: * Platform....: VFP 6.0 and VFP 7.0 * Created.....: &&RS 2003.06.06 * History.....: && 1999.10.19 Use SYS(16) to get name of EXE file. && 2001.09.29 DONE: copy EXE file to C: drive before executing. &&RS 2002.01.23 Recompiling under VFP 6. &&RS 2003.06.05 Copy EXE file to C:\MASSONE\ directory. &&RS 2003.06.06 TODO: handle general case by adding 'X' after file name. &&RS 2003.06.30 Include VFP6RENU.DLL in copy list. &&RS 2003.06.30 Copy file any time date-time does not match. &&RS 2004.07.07 Update for VFP Version 7. &&RS 2004.07.17 More comments. ********************************************************************** lparameter tcProgram1, tcProgram2, tcLocalDirectory local lcStartDirectory, lcLocalDirectory local lcFoxTools1, lcFoxTools2 local lcFileDate local lcFileTime local lcNoLoginMsg local lcProgram1, lcProgram2 local lcProgName, lcProgXName local lnPos local ltFileDateTime *!* wait*window "Program(0) = " + Program(0) + " Program(1) = " + Program(1) *!* wait*window "Sys(16) = " + Sys(16) if type("tcProgram1") = "C" lcProgram1 = alltrim(upper(tcProgram1)) else lcProgram1 = "" endif if type("tcProgram2") = "C" lcProgram2 = alltrim(upper(tcProgram2)) else lcProgram2 = "" endif if type("tcLocalDirectory") = "C" lcLocalDirectory = alltrim(upper(tcLocalDirectory)) else lcLocalDirectory = "" endif if empty(lcLocalDirectory) lcLocalDirectory = "C:\MASSONE\" else if not right(lcLocalDirectory,1) == "\" lcLocalDirectory = lcLocalDirectory + "\" endif endif lcStartDirectory = upper(alltrim(sys(2003))) + "\" do case case not empty(lcProgram1) lcProgName = juststem(lcProgram1) case not empty(lcProgram2) lcProgName = juststem(lcProgram2) otherwise lcProgName = juststem(sys(16)) do case case "MASSONE" $ lcStartDirectory and "LAUNCH" $ lcProgName lcProgram1 = lcStartDirectory + "MASSONE.EXE" case "MASSPLAY" $ lcStartDirectory lcProgram1 = lcStartDirectory + "MASXPLAY.EXE" case "MASSREAL" $ lcStartDirectory and lcProgName == "LAUNCHER" lcProgram1 = lcStartDirectory + "MASXNEW.EXE" lcProgram2 = lcStartDirectory + "MASXONE.EXE" case lcProgName == "MASSONE" lcProgram1 = lcStartDirectory + "MASXONE.EXE" lcProgram2 = lcStartDirectory + "MASXNEW.EXE" case lcProgName == "MASSNEW" lcProgram1 = lcStartDirectory + "MASXNEW.EXE" lcProgram2 = lcStartDirectory + "MASXONE.EXE" case "MASS" $ lcProgName lcProgName = strtran(lcProgName,"MASS","MASX") && MASSTEST --> MASXTEST etc. lcProgram1 = lcProgName + ".EXE" lcProgram2 = "" otherwise if empty(lcProgram1) messagebox("Program name is empty.") else messagebox("Program " + lcProgram1 + " not recognized.") endif return endcase endcase do case case not empty(lcProgram1) and file(lcProgram1) ** lcProgram1 is OK case not empty(lcProgram2) and file(lcProgram2) lcProgram1 = lcProgram2 otherwise messagebox("Program " + lcProgName + " cannot be located at this time.") return endcase if file("NOLOGIN.TXT") lcNoLoginMsg = filetostr("NOLOGIN.TXT") if empty(lcNoLoginMsg) lcNoLoginMsg = "Program " + lcProgName + " is not available at this time." endif messagebox(lcNoLoginMsg) return endif if not directory(lcLocalDirectory) mkdir (lcLocalDirectory) &&RS 2003.06.12 endif lcProgXName = justfname(lcProgram1) lcProgram2 = lcLocalDirectory + lcProgXName ** lcProgram1 is the network path name of the program to copy ** lcProgram2 is the local path name of the program to execute if not LatestVersion(lcProgram1,lcProgram2) return endif &&RS 2004.07.07 TODO: use function ExeVersion to copy only needed files. LatestVersion(lcStartDirectory+"DLL\VFP6R.DLL", lcLocalDirectory+"VFP6R.DLL") LatestVersion(lcStartDirectory+"DLL\VFP6RENU.DLL", lcLocalDirectory+"VFP6RENU.DLL") LatestVersion(lcStartDirectory+"DLL\VFPODBC.DLL", lcLocalDirectory+"VFPODBC.DLL") LatestVersion(lcStartDirectory+"DLL\VFPOLE50.DLL", lcLocalDirectory+"VFPOLE50.DLL") LatestVersion(lcStartDirectory+"DLL\VFP6RUN.EXE", lcLocalDirectory+"VFP6RUN.EXE") LatestVersion(lcStartDirectory+"DLL\VFP7R.DLL", lcLocalDirectory+"VFP7R.DLL") LatestVersion(lcStartDirectory+"DLL\VFP7T.DLL", lcLocalDirectory+"VFP7T.DLL") LatestVersion(lcStartDirectory+"DLL\VFP7RENU.DLL", lcLocalDirectory+"VFP7RENU.DLL") LatestVersion(lcStartDirectory+"DLL\VFP7RUN.EXE", lcLocalDirectory+"VFP7RUN.EXE") LatestVersion(lcStartDirectory+"DLL\FOXHHELP7.EXE", lcLocalDirectory+"FOXHHELP7.EXE") LatestVersion(lcStartDirectory+"DLL\FOXHHELPPS.DLL", lcLocalDirectory+"FOXHHELPPS.DLL") LatestVersion(lcStartDirectory+"DLL\FOXTOOLS.FLL", lcLocalDirectory+"FOXTOOLS.FLL") LatestVersion(lcStartDirectory+"DLL\MSVCR70.DLL", lcLocalDirectory+"MSVCR70.DLL") LatestVersion(lcStartDirectory+"DLL\MSXML3.DLL", lcLocalDirectory+"MSXML3.DLL") LatestVersion(lcStartDirectory+"DLL\MSXML3R.DLL", lcLocalDirectory+"MSXML3R.DLL") LatestVersion(lcStartDirectory+"DLL\MSXML3A.DLL", lcLocalDirectory+"MSXML3A.DLL") LatestVersion(lcStartDirectory+"METADATA\DBCXREG.DBF", lcLocalDirectory+"DBCXREG.DBF") LatestVersion(lcStartDirectory+"METADATA\DBCXREG.CDX", lcLocalDirectory+"DBCXREG.CDX") LatestVersion(lcStartDirectory+"METADATA\DBCXREG.FPT", lcLocalDirectory+"DBCXREG.FPT") LatestVersion(lcStartDirectory+"METADATA\CDBKMETA.DBF", lcLocalDirectory+"CDBKMETA.DBF") LatestVersion(lcStartDirectory+"METADATA\CDBKMETA.CDX", lcLocalDirectory+"CDBKMETA.CDX") LatestVersion(lcStartDirectory+"METADATA\CDBKMETA.FPT", lcLocalDirectory+"CDBKMETA.FPT") LatestVersion(lcStartDirectory+"METADATA\FEMETA.DBF", lcLocalDirectory+"FEMETA.DBF") LatestVersion(lcStartDirectory+"METADATA\FEMETA.CDX", lcLocalDirectory+"FEMETA.CDX") LatestVersion(lcStartDirectory+"METADATA\FEMETA.FPT", lcLocalDirectory+"FEMETA.FPT") run /n &lcProgram2 return *********************************************************************** * FUNCTION JUSTFNAME *********************************************************************** * Purpose.....: Return the file name of a file without the path. * Parameters..: tcPathName * Returns.....: character * Notes.......: Including this function so that we don't require FOXTOOLS. *********************************************************************** function justfname lparameter tcPathName local lcPathName local lnPos local lcFileName lcPathName = upper(alltrim(tcPathName)) lnPos = rat( "\",lcPathName) if lnPos = 0 lcFileName = lcPathName else lcFileName = alltrim(substr(lcPathName + " ",lnPos+1)) endif return lcFileName *********************************************************************** * FUNCTION JUSTSTEM *********************************************************************** * Purpose.....: Return the stem name (first eight characters of file * name) from a complete path and file name. * Parameters..: tcPathName * Returns.....: character * Notes.......: Including this function so that we don't require FOXTOOLS. *********************************************************************** function juststem lparameter tcPathName local lcPathName local lnPos local lcStemName lcPathName = upper(alltrim(tcPathName)) lnPos = rat( "\",lcPathName) if lnPos = 0 lcStemName = lcPathName else lcStemName = alltrim(substr(lcPathName + " ",lnPos+1)) endif lnPos = rat(".",lcStemName) if lnPos > 0 lcStemName = left(lcStemName,lnPos-1) endif return lcStemName *********************************************************************** * FUNCTION LATESTVERSION *********************************************************************** * Purpose.....: Copy the current version of the passed file to a specified * directory and file name. * Parameters..: tcFileName1 -- Network version of resource file. * tcFileName2 -- Local version of same resource file. * Returns.....: true if successful. *********************************************************************** function LatestVersion lparameter tcFileName1, tcFileName2 local ltDT1, ltDT2 if not file(tcFileName1) Msg_RS("LAUNCH_RS: <Can't find> " + tcFileName1,"MD") return .f. endif if not file(tcFileName2) set message to "Copying " + tcFileName1 + " to " + tcFileName2 copy file (tcFileName1) to (tcFileName2) if file(tcFileName2) return .t. &&RS 2003.06.11 else Msg_RS("LAUNCH_RS: <Could not copy to> " + tcFileName2,"MD") return .f. endif endif ltDT1 = fdate(tcFileName1,1) &&RS 2003.06.07 '1' in 2nd param produces datetime value if empty(ltDT1) Msg_RS("LAUNCH_RS: <Can't get date and time for_M1> " + tcFileName1,"ML") return .f. endif ltDT2 = fdate(tcFileName2,1) if empty(ltDT2) Msg_RS("LAUNCH_RS: <Can't get date and time for_M1> " + tcFileName2,"ML") return .f. endif **wait*window tcFileName1 + " " + ttoc(ltDT1) + " " + tcFileName2 + " " + ttoc(ltDT2) if not ltDT1 == ltDT2 set message to "Copying " + tcFileName1 + " to " + tcFileName2 set safety off copy file (tcFileName1) to (tcFileName2) set safety on endif return .t.Hope this helps.