Please enable JavaScript to view this site.

Navigation: Scripts > Running a Prism script

Run a script using Automator, MacScript, or AppleScript

Scroll Prev Top Next More

Run a script using Automator

If you use OSX 10.4 (“Tiger”) or later, Prism installs an Automator Action that lets you launch a Prism script. The inputs to this Action is either a file containing a Prism script, or the text of the script itself. The output is either the word “Done” or an error message.

Run a script from Microsoft Office using MacScript

MacScript commands let you launch Prism from Word or Excel. These examples assume you are running Visual Basic for Applications (VBA) from within Excel.

Launch Prism with this MacScript command.

MacScript “tell application “”HD:Prism4:Prism””” + Chr(13) + _

“activate” + Chr(13) + _

“open file “”Macintosh HD:Prism4:Scripts:dr2””” + Chr(13) + _

“end tell”

The MacScript command has to specify both the full location of Prism and the script that Prism will launch. The MacScript command is a Visual Basic statement that you will need to write in an Excel macro, perhaps one that runs when the user clicks a button.

As soon as Visual Basic has launched Prism, it will continue to the next statement in the Visual Basic program or macro. It will NOT wait for Prism to complete before continuing. If you don't take the extra steps described below, your Visual Basic program will try to read a file containing Prism’s results before Prism has finished creating that file. To avoid this, make your Visual Basic program pause until Prism creates a file.

When you write the Prism script, include lines at the end of the script to create a file that will tell Visual Basic you are done. The example below creates done.txt.

OpenOutput "done.txt"

WText "done"

CloseOutput

Your Visual Basic code should first delete the file done.txt (if it exists from a previous run) and then launch Prism. Immediately following, include these lines that make your program loop until done.txt is created.

Do Until Dir$(“HD:prism 5:done.txt") > ""

Application.Wait Now + TimeValue("00:00:1")

Loop

The first line in the example above checks whether the file done.txt exists. Change the path and file name as needed. If the file exists (Prism is done), Visual Basic continues beyond the loop with any code that follows. If the file doesn't exist yet, Visual Basic waits 1 second, and then loops back to test again whether the file exists.

MacScript “tell application “”HD:Prism4:Prism””” + Chr(13) + _

“quit” + Chr(13) + _

“end tell”

 

Run a script from AppleScript

Here is a sample AppleScript that launches Prism and tells it to run the script named DR2 located in the P4scripts folder on a disk named HD.

tell application "HD:Applications:Prism4 Folder:Prism"

  activate

  open file “HD:P4scripts:DR2.pzc”

end tell

Note that are two ways to specify the path. The example above uses a HFS path. Here is the same example using a POSIX path.

tell application "HD:Applications:Prism4 Folder:Prism"

  activate

  open POSIX file “/P4scripts/DR2.pzc”

end tell

With the Posix style, you use slashes (not colons) and must have the opening slash.

 

 

 

 

 

 

 

© 1995-2019 GraphPad Software, LLC. All rights reserved.