Setting up an ‘Add-in Depot’ makes it easy to administer a collection of self-updating JMP add-ins. In this example, the Depot is nothing more than a folder containing:
- The JMP add-in file “com.jmp.brady.addin1.jmpaddin”.
- A metadata file, “File Metadata.jmp”.
In a typical case, the add-in depot will reside on a server folder where add-in users have read access.The metadata file is a JMP table that stores information about each add-in in the depot. In this example, we will use it to check when the add-in was most recently published.If the add-in is current when the user runs it, the add-in will run without fanfare. However, if the user attempts to run an outdated version of the add-in, he or she will receive a prompt to install the new version:If the user clicks “Cancel”, the present addin will run. If he or she clicks “OK” the update will install automatically, overwriting the outdated version. In this example, the user is informed of the install and prompted to re-run the addin:
Self-updating JMP add-ins: a step-by-step example.
- Open “Hello Script.jsl”.
- Ensure line that 10 has the date 08/01/2012 between the quotes.
- Ensure that line 22 has the string “Hello world” as the textbox argument.
- Note: Line 15 calls the check_for_updates function, which is not contained in our main script, but is contained in “update_functions.jsl”. This is the reason for the include statement on line 13. This is nice because it keeps our main script simpler, but we will need to make sure to include “update_functions.jsl” as an extra file whenever we build an add-in.
- Save and close the file.
- Open “File Metadata.jmp”:
- Note that the filename in the “File” column must be the same as the string assigned to “Addin_Name” in line 11 of the script above.
- Ensure the publish date is 08/01/2012, Change it if needed, then save and close.
- Open “update_functions.jsl”:
- On line 4, set the depot_path variable to the folder you will use for your depot.
- Note that the meta_file variable on line 5 must match the name of the metadata file.
- Save and close this file.
- Build the add-in:
- From the JMP menu, select File >> New >> New Add-In
- On the ‘General Info’ tab:
- Enter the add-in name, in this example “Hello World”.
- Enter the add-in ID. Whatever you enter here must exactly match both the File column in the Metadata file, and the Addin_Name string in “Hello Script.jsl”.
- On the ‘Menu Items’ tab:
- Click the “Add” button.
- In the ‘General’ panel’s ‘Menu item name” textbox, enter the name you would like to appear on the Add-in drop-down menu.
- In the ‘Action’ panel, select the ‘Run JSL in this file:’ radio button.
- Click ‘Browse’ and add the “Hello Script.jsl” file.
- On the ‘Additional Files’ tab:
- Click ‘Add’.
- Browse to the “update_functions.jsl” file and add it.
- Click ‘Save’, and save the new .jmpaddin file to a convenient location.
- Set up the depot:
- Place the .jmpaddin file you just created, along with the file “File Metadata.jmp”, in the folder you specified as your add-in depot folder (line 4 of the “update_functions.jsl” file.)
- Test the addin:
- From the JMP menu bar, select Add-Ins >> Hello World (or, whatever you entered as the menu item text), and the simple “Hello World” window will appear.
- Click ‘OK’ to close the window.
- Create an updated version of the add-in:
- Open “Hello Script.jsl”.
- Change line 10 to have the date 10/01/2012 between the quotes.
- Change line 22 to have string “Hellooooooooo world” as the textbox argument.
- Save and close the file.
- Perform steps 4a through 4d exactly as before, with the following important exception:
- When building the add-in, on the ‘General Info’ tab, make sure the “Install after save” box is NOT checked.
- Place the .jmpaddin file you just built in the depot, overwriting the older .jmpaddin file.
Note that we have not yet published the add-in, as we have yet to change the publish date in the metadata file. To see this, from the JMP menu select Add-Ins >> Hello World (or whatever you entered as the menu item text) and the “Hello World” window will appear as before.
- Publish the add-in:
- Open “File Metadata.jmp”. Change the publish date to 10/01/2012. Save and close the file.
- Test the automatic update:
- From the JMP menu, select Add-Ins >> Hello World. The add-in will determine that an update is available, and present you with the update window.
- Click ‘Cancel’ to refuse the update and see the “Hello World” window as before.
- Select Add-Ins >> Hello World to run the add-in again.
- This time, when the update window appears, click ‘OK’ to accept the update.
- Click ‘OK’ to close the confirmation window.
- Run the add-in again. The new add-in will run, showing “Hellooooooooo World” as the window text.