Vince Lackner (The Lackner Group, Inc., Pittsburgh, USA) developed a routine with FileMaker and Troi File Plug-in to automate the update of solutions:
NOTE This page was created in 2004 and uses FileMaker Pro 6 and Troi File 2.8. The information below is still valid for FileMaker 6.
“At the recent suggestion of Dana Perry, I took a look at the Troi File Plug-in in the context of testing for the existence of the Adobe Acrobat Reader program (before launching PDF files from FileMaker).
My study of the plug-in confirmed for me the great power of this tool for a variety of other tasks, including the automation of upgrades.
I developed a routine with FileMaker and the Troi File Plug-in that I thought might interest other users.
Its purpose is to determine what subfolders already exist with a name formatted as “!BakXYZ” where “XYZ” is a number from “001” through “999”. This routine is described below (after my outline of the general update procedure).
General update procedure
The general idea is the following:
1) Existing FileMaker Pro files have an extension of “USR”.
2) A new version of the program installs new FileMaker Pro files with an extension of “_SR”.
3) This same new version of the program also installs a simple text file called “Update1.txt”.
4) When a user launches the Opener.USR file after installing the new files, FileMaker (with the Troi File Plug-in) looks for the existence of Update1.txt.
5) If it finds this file, it launches the conversion script that does the following:
a) Deletes all of the *.OLD files that might still be there from the last conversion.
b) Determines the current !Bak subfolder with the highest number (i.e., !Bak005), then creates a new subfolder that is one higher (i.e., !Bak006).
c) Copies all of the *.USR files to !Bak006.
d) Renames all of the *.USR files to *.OLD (except for Opener.USR, which is the file that is launching the Troi File Plug-in scripts).
e) Renames all of the new *._SR files to *.USR.
f) Launches the external scripts (one in each of the new FileMaker Pro files) that import the data from *.OLD to *.USR. Each script first calls a FindAll (Show All Records) script in the *.OLD file before importing the data from that file.
g) Closes all of the *.OLD files.
h) Deletes the Update1.txt file so that the next time that the Opener.USR file is launched (to start the program), FileMaker Pro will not launch the conversion routine. Thus, the conversion routine won’t be launched again until another update in installed.
At this time, I could delete the *.OLD files, but have decided to keep them there just in case there is a problem with Step (c) above (copying all of the *.USR files to !Bak006). Of course, I plan to trap for such a problem and halt the conversion routine right there, but keeping the *.OLD files in the main folder until the next conversion should do no harm.
Creation of backup subfolders
I use a PatternCount function to test for the existence of ANY subfolder that starts with “!Bak”. If none exists, then I use Troi to create a subfolder called “!Bak001”. If at least one exists, then I needed to figure out the highest number of all those that do exist. I do this by testing for subfolders that start with “!Bak9”, and decrement the “9” until I find an existing subfolder that starts with “!BakX”. I then test for subfolders that start with “!BakX9”, and decrement the “9” until I find an existing subfolder that starts with “!BakXY”. Finally, I test for subfolders that start with “!BakXY9”, and decrement the “9” until I find an existing subfolder whose name is “!BakXYZ” (i.e., “!Bak005”). I now know that this is the highest existing subfolder name. I increment my global to “!Bak006” and use Troi to create a new subfolder with that name. This procedure is extremely fast, because it is analyzing a list of subfolders that is read into an FMP field one time at the very beginning of the procedure.
Here are the two scripts:
1) Test for Highest !Bak Number (the zv_folderList is populated in Script #2 below, which calls this script)
If [PatternCount (zv_folderList,"!Bak" = 0 ] Set Field [zv_highestExistingFolderNum, 0] Else
Set Field [zv_counterHundreds,9] Set Field [zv_counterTens,9] Set Field [zv_counterOnes,9] Loop
Exit Loop If [PatternCount(zv_folderList,"!Bak" & zv_counterHundreds) > 0 ] Set Field [zv_counterHundreds, zv_counterHundreds - 1] End Loop
Exit Loop If [PatternCount(zv_folderList,"!Bak" & zv_counterHundreds & counterTens) > 0 ] Set Field [zv_counterTens, zv_counterTens - 1] End Loop
Exit Loop If [PatternCount(zv_folderList,"!Bak" & zv_counterHundreds & counterTens & counterOnes) > 0 ] Set Field [zv_counterOnes, zv_counterOnes - 1] End Loop
Set Field[zv_highestExistingFolderNum, TextToNum(zv_counterHundreds & zv_counterTens & zv_counterOnes] End If
2) Create !BakXYZ Directory
Perform Script ["List Folders"] If [PatternCount(zv_folderList, "!Bak001") = 0] Set Field [zv_highestExisting FolderNum, 0] Set Field [zv_errorCode, External("TrFile-CreateFolder", z_newFolderPath)]<==TROI
Perform Script ["Test for Highest !Bak Number"] [Sub-scripts] Set Field [zv_errorCode, External("TrFile-CreateFolder", z_newFolderPath)]<==TROI
Set Field [zv_highestExistingFolderNum, zv_highestExistingFolderNum + 1] Perform Script ["List Folders"] [Sub-Scripts]
There have been other ideas on the topic of installing updates to FMP data files. I welcome all suggestions for improvements to the above procedure.
Click here if you want to download a zipped copy of the small Opener.USR file that contains the fields and scripts necessary to support this operation.
The Lackner Group, Inc.
Web page: www.lacknergroup.com”