Automation Reference - JMP
Automation Reference - JMP
Automation Reference - JMP
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Application Object <strong>Reference</strong> for Automating <strong>JMP</strong><br />
Automating <strong>JMP</strong> through Visual Basic<br />
Automating <strong>JMP</strong> through Visual Basic<br />
Starting a <strong>JMP</strong> application<br />
The first step in automating <strong>JMP</strong> is to start it up. However, it’s important to look at the resources available to help<br />
you with the <strong>JMP</strong> methods and properties. <strong>JMP</strong> provides a type library that allows automation controllers like Visual<br />
Basic (VB) to display a list of the methods and properties that <strong>JMP</strong> exposes, along with parameters that the methods<br />
require. This library is called <strong>JMP</strong>.TLB.<br />
There are two steps to make the <strong>JMP</strong> type library available to VB.<br />
1. Select Project > <strong>Reference</strong>s in VB. A list of applications that are known to VB appears. If <strong>JMP</strong> is not in that<br />
list, select Browse. A file window asks you to locate a .tlb (Type library) file. Find the icon for the <strong>JMP</strong> type<br />
library in the <strong>JMP</strong> directory. Select this library and click OK.<br />
2. Open the object browser by selecting View > Object Browser in VB. Select <strong>JMP</strong> from the drop down list box.<br />
Now you can see the <strong>JMP</strong> automation classes and constants. You can now select a class, and the methods available to<br />
that class appear in the right list box for the object browser. If you select a method, a short helper string appears at the<br />
bottom of the window. This string lists the parameters for the method. Constants are used when methods require a<br />
restricted set of parameters, typically denoting a specific action.<br />
Now that you have access to the type library information, write the necessary code to instantiate <strong>JMP</strong>. This is done<br />
with CreateObject. In global declarations for the VB project, create a variable of type <strong>JMP</strong>.Application. This is<br />
done as:<br />
Dim My<strong>JMP</strong> As <strong>JMP</strong>.Application<br />
Now dimension some other variables. Good examples are DataTable, Distrib, Oneway, and <strong>JMP</strong>Doc. These are<br />
specified with <strong>JMP</strong>.DataTable, <strong>JMP</strong>.Distribution, <strong>JMP</strong>.Oneway, and <strong>JMP</strong>.Document respectively.<br />
To create a <strong>JMP</strong> session, make it visible, and load a data table, add the following code to your VB script.<br />
Dim <strong>JMP</strong>Doc As <strong>JMP</strong>.Document<br />
Set My<strong>JMP</strong> = CreateObject("<strong>JMP</strong>.Application")<br />
My<strong>JMP</strong>.Visible = True<br />
Set <strong>JMP</strong>Doc = My<strong>JMP</strong>.OpenDocument("C:\Program Files\SAS\<strong>JMP</strong>\10\Samples\Data\Big Class.jmp")<br />
The Dim statement indicates the type of variable. This declaration should go in the general declarations section of<br />
your VB project, though. If you do not do this, the <strong>JMP</strong> objects are destroyed when the variable goes out of scope at<br />
the end of the procedure.<br />
<strong>JMP</strong> comes up invisible by default, as required by automation guidelines. Therefore, one of your first moves should<br />
be to make it visible, as shown in the above code.<br />
Launching an analysis<br />
Now that you have a data table open, you can launch an analysis and manipulate it. Each analysis must first be<br />
created. Then, the required parameters for the analysis must be specified. Optional settings can also be specified.<br />
Then the analysis is launched. Additional option processing can then be done on the analysis object after the launch.<br />
Dim Oneway As <strong>JMP</strong>.Oneway<br />
Set Oneway = <strong>JMP</strong>Doc.CreateOneway<br />
Oneway.LaunchAddY ("Height")<br />
Oneway.LaunchAddX ("Age")<br />
'Set an option before the launch<br />
Page 2