One way to launch a script is from within Prism (drop the File menu and choose Run Script). You can also launch a Prism script from outside Prism. When you launch Prism this way, if the script closes all open Prism files, then Prism will shut down when the script ends. Otherwise Prism will remain open.
Launching a Prism script from a desktop icon
To create an icon that launches a Prism script, point your mouse to an empty spot on the desktop, click the right mouse button and select New… Shortcut. Enter a command line that starts Prism and points to the Prism script file to launch. Include the @ symbol in front of the path to the script name. If either path includes spaces, include the entire path in quotes as shown below:
“C:\PRISM5\PRISM.EXE” @”C:\PROGRAM FILES\PRISM 6\SCRIPTS\DOIT.PZC”
Shelling to Prism from another program
To "shell" simply means to launch one program from another. Here is an example of a shell command in an Excel VBA macro.
Shell ("C:\prism 5\prism.exe @C:\prism 6\dr2.pzc")
The shell command has to specify both the full location of prism.exe and the script that Prism will launch. Include the @ symbol in front of the script name.
Two important notes:
•Prism will run invisibly. Even when it is done, Prism will not show on screen.
•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, as explained below.
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$(“C:\prism 6\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.
Launching Prism from another program using OLE automation
An alternative to the Shell command is to launch Prism using OLE (or Active X) automation. Here is an example.
Set Prism = CreateObject("Prism.command")
Prism.SetPath (”C:\data\july99”)
Prism.visible
Prism.runcommand (“c:\prism5\doseresp.pzc")
Prism.quit
Set Prism = Nothing
The first line creates a Prism command object. You may give the object variable any name you like (on the left side of the = sign), but it is convenient to name it Prism. You don’t have to tell the program the location of prism.exe. Windows takes care of this automatically via the registry.
The second line, which is optional, tells Prism which folder to use. This replaces the need for a SetPath statement within the Prism script. When running a script, Prism looks for data files and templates in this directory (folder) first. Place the name of the folder in quotation marks or use a text variable.
The third line tells Prism to show its progress dialog. Once you have tested your code, remove this line so Prism will run invisibly (show no dialogs).
The fourth line launches the Prism script. You must include the full path of the script file; the directory used in the SetPath message (above) is not used automatically.
The final two lines cause Prism to exit, and free the memory used by the Prism object.
Shell command vs. VBA automation
There are two advantages to using OLE automation, rather than the Shell statement. First, with OLE automation Visual Basic and Prism run sequentially, with no possibility of Visual Basic trying to obtain results that haven't been created yet. Second, with OLE automation, your Visual Basic program can direct Prism to import data from a particular folder (Prism.SetPath command) without changing the Prism script.
Launching a script from an intranet web page (Windows)
You can launch Prism from a link on an intranet web site.
First, create a batch file on your web server that calls (using the Call command) the program and individual configuration files.
For example, create a file called StartPrism.bat containing a single line something like this
Call “N:\Program Files\PRISM5\PRISM.EXE” -OC:\WINDOWS\prism5.cnf
Or this:
Call F:\Prism\Prism.exe @"F:\PRISM\PRISMSCRIPTS\DOIT.PZC"
Of course, you'll need to adjust this example depending on where you have installed Prism. The drive letters are aliases for the server drive. In the first example, the first part opens Prism and the second part tells Prism where to find the configuration file. In the second example, the second part launches a Prism script.
Next edit your web page to include a hyperlink to the batch file. For example, HTML link the text "Prism" to the file StartPrism.bat