Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Jun 16, 2011 1:31 PM
| Last Modified: Apr 8, 2019 9:04 AM
JMP 9 introduced an add-in architecture that makes creating and distributing extensions to JMP easy. This makes JMP a platform for creating new analytic tools. It also makes it easy to add new functionality. Creating a JMP add-in is pretty simple. All you need to know is JMP Scripting Language (JSL).
There are two distinct phases to the process of creating a JMP add-in: development and deployment.
We'll cover development first.
Begin the process of developing your add-in by creating a folder to contain all the pieces that your add-in might require. This is your "add-in folder".
Next, you'll need to decide on some names.
Each JSL add-in must have a unique ID. This is a name that is rarely seen by the end user of an add-in. We suggest that you use something like the reverse DNS naming convention to create this unique name.
For this example, I'll call my add-in "com.jmp.jperk.texttocols".
An add-in also has a display name, which is what the user will see most of the time. This is a friendlier name, and there is no requirement for uniqueness with this name. I'll call mine "Text to Columns".
In your add-in folder, create a text file called "addin.def".
The contents of this file should be as follows, substituting your unique ID and display name as appropriate:
name="Text to Columns"
Now, you need to register your add-in with JMP. Do this by opening the addin.def file with JMP. When you do this, JMP will prompt you to ask if you want to install your add-in.
This seems odd at first, but you'll need this so JMP knows about your add-in as you develop it. Go ahead and click "Install" to complete the registration.
This registration connects the ID for your add-in with your add-in directory. You can now reference this directory using the $ADDIN_HOME(uniqueID) path variable. For example, you could use the include function like this:
Now begin writing the JSL for your add in. Save it into your add-in directory.
As you write your JSL, if you need to refer to any external files, like data or a DLL, put them in your add-in directory. You should use the $ADDIN_HOME(uniqueID) path variable to reference them in your JSL code.
After your JSL is complete, you'll need to build a custom menu, so users of your add-in can access it.
Go to View->Customize->Menus and Toolbars to launch the menu editor.
Click the "Change..." button at the top of the editor to change to editing customizations for your add-in.
Now, you can create a custom menu item to launch your JSL. I'm putting mine in the Columns menu after a separator.
Give your menu command a unique, Internal Name. This is the name that JMP will use to find this menu item if it's referred to by other custom menus. Next, put the text of the menu item itself in the Caption field. This is what will be shown in the menu. You can also insert a tooltip in the Tip field. Use the Localize buttons to put localized versions of the Caption and Tip, if you desire.
In the "Action" section, choose "Run JSL in this file" and then click the the checkbox next to "Use add-in home folder" and make sure that your add-in ID is chosen.
Note the "Icon" section where you could use an image file from your add-in home folder as the icon for your menu item.
When you click "OK", JMP will save the customization file you just created in your add-in directory as "addin.jmpcust".
You're now ready to package your add-in for deployment. You need to create a .ZIP archive of: 1) addin.def, 2) addin.jmpcust, 3) your .JSL file and any other dependencies.
You'll need to change the ".zip" extension on the archive to ".jmpaddin".
Now you can test your packaged add-in.
Start by Unregistering the development version of your add-in. (View->add-ins)
Now, double-click on the .jmpaddin file that is now your deployable add-in.
JMP will ask you if you'd like to install your add-in.
After you install it, you'll see it listed in the View->Add-ins... dialog. Note that the directory is not your add-in directory but a directory in the user area for JMP.
JMP has expanded the .zip archive into this user area. Click on the directory name in the dialog to see its contents. This is convenient for looking at any JSL used by an add-in.
Finally, you can go to the custom menu created by the add-in to launch it.