Using Scripts
PublishPlot is a scriptable application, which allows you create many new features for working with your plots or processing data in your plots. This help topic explains how to use scripts. See the help on Writing Scripts to learn how to write your own scripts to create custom features. If you are not a programmer, see below to learn about some scripts available for downloading.
Scripts Menu
Although scripts can be run from scripting software (such as Apple's Script Editor), it is more convenient to let PublishPlot run scripts for you. To enable this option, select a scripts folder and store your scripts within that folder (or within subfolders within that folder). Each script in that folder will be a new "feature" in PublishPlot that can be used by choosing it (by name) from the "Scripts" menu.
The "Scripts" menu is activated and used as follows:
- Link to "Scripts" folder: when you first start to use PublishPlot, it will not be linked to a "Scripts" folder. To select a folder, choose the "Link to folder..." command in the initial "Scripts" menu. Once linked, all Apple Script files (with extensions
.scptor.applescript) in that folder (and its subfolders) will appear in the "Scripts" menu. - Run a Script: to run any script, choose it from the "Scripts" menu.
- Add to "Scripts" folder: once a "Scripts" folder is linked, you can move or save any scripts you write or download into that folder. For convenience, the "Reveal Scripts in Finder" menu command will open your selected folder in the MacOS Finder. Drag your scripts into the window that opens.
- Refresh Scripts: if you drag or save scripts to your selected folder while PublishPlot is running, choose the "Refresh Scripts" menu command to update the list of available scripts in the "Scripts" menu.
- Change "Scripts" folder: if you want to use scripts in a different folder, open the settings window, click on the "Link Scripts Folder" button in the "General" tab, and pick the new folder.
Two Sample Scripts
When you first link to a scripts folder, or change to link to a new folder, PublishPlot will copy two sample scripts into that new folder:
Sample Plot- this script demonstrates how to create a plot and add it to the front window (or a new window if needed). It is the same script explained in the help on writing scripts.Integrate Plot- this script numerically integrates the selected plot (or front-most plot if none selected) in the front window. It demonstrates doing calculations on an existing plot in a PublishPlot document.
Note that if the new scripts folder already has these scripts, the ones in that folder will be left intact and copying of these examples will be skipped. See the next section to learn how to populate the "Scripts" menu with more scripts.
Assigning Keyboard Equivalents to Scripts Menu Commands
The commands in the "Scripts" menu can be assigned to an option-command keyboard equivalent by editing the script as follows:
- Choose "Reveal Scripts in Finder" to show your scripts in a Finder window.
- Open (by doubling clicking) any script in Apple's Script Editor.
- Make the first line of the script begin in "
-- optionKey:k" (case sensitive) where "k" is the desired keyboard equivalent. - Save the script, but note the script must be saved with extension
.applescriptand not.scpt. If you have a.scptfile, you can duplicate it and save as an.applescriptfile by choosing "Text" for its "File Format" when saving in Script Editor. Once converted, you can delete the prior.scptversion.
Note that using a lower case letter will result in option-commmand-key keyboard equivalent while using a upper case letter will result in shift-option-command-key keyboard equivalent. You have to be sure to choose unique keys for you scripts (any duplicates will be ignored). You also have to avoid key combinations hogged by the MacOS (for example option-command-D shows and hides the Dock and therefore cannot be used for a script).
Obtaining Scripts
Writing Scripts
If you are proficient at writing AppleScripts (or willing to learn), writing you own scripts is a powerful option for adding new features to PublishPlot. If you find yourself repeating the same actions over and over again, it might be time to write a script to automate all those actions. All the information you need to write scripts is provided in the Writing Scripts help topic.
Downloading Scripts
If you are not a programmer, you can still make using of scripting options by downloading and installing scripts available on the PublishPlot web site.