14.03.2014 Views

Automation Reference - JMP

Automation Reference - JMP

Automation Reference - JMP

SHOW MORE
SHOW LESS

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 C++<br />

Automating <strong>JMP</strong> through Visual C++<br />

Using C or C++ to create an automation client can be a long, tedious task. However, if you use the support provided<br />

by MFC in Microsoft Visual C++, the task is considerably easier. There are several steps that must be performed in<br />

order to get to a state where you can launch the automation server application (<strong>JMP</strong> in this case). The AutoClient<br />

application that is included in the Visual C++ Sample directory contains some code that provides ideas on how to get<br />

started. The Microsoft sample application CALCDRIV also shows a MFC-based automation client. CALCDRIV is<br />

typically included with Visual C++, and on MSDN CDs.<br />

AutoClient shows how to start up <strong>JMP</strong> and drive a Bivariate analysis and the data table. The sample is much smaller<br />

than any of the Visual Basic samples, but the mechanics behind all the automation calls that you might want to use<br />

are the same as the examples with Bivariate and the data table. The following steps are based on the Visual C++<br />

Version 5.0 UI.<br />

Steps for automating <strong>JMP</strong><br />

1. Create your application, either manually or through App Wizard. Specify support for OLE automation. Even if<br />

you are not automating your own application, you need to include the OLE headers and initialization code. If<br />

you are retrofitting an existing application, you need to make sure that you include OLE support. This usually<br />

means including afxole.h in your application, and calling AfxOleInit() in your application InitInstance<br />

routine. Consult the MFC OLE documentation for details about this.<br />

2. Bring up the Class Wizard and select the <strong>Automation</strong> tab. Select the Add Class drop down list and then the<br />

From a Type Library option. Navigate to the <strong>JMP</strong> install directory until you find <strong>JMP</strong>.TLB. Select this type<br />

library.<br />

3. You are prompted to confirm the classes that you want to use in your project. If you are unsure what objects (and<br />

interfaces) that you want, select them all by Shift-clicking. Select the names for the files where the class wizard<br />

generates interface stubs and header information. Class Wizard is generating wrapper classes based on the MFC<br />

ColeDispatchDriver class. This gives you easy access to the OLE Invoke automation function without having to<br />

know a lot of the technical details. Select OK. Class Wizard generates the two files (.h and .cpp). You should<br />

include the .h file in whatever .cpp files use the <strong>JMP</strong> automation objects. For example, your View class<br />

implementation file.<br />

4. The Class View of your Workspace now shows the Interface classes that you have imported. You can examine the<br />

methods and properties for each class through this class view.<br />

5. To start <strong>JMP</strong>, define a variable of type I<strong>JMP</strong>AutoApp that persist for the length of the automation session. Call<br />

CreateDispatch on this variable, passing in the <strong>JMP</strong> ProgID (“<strong>JMP</strong>.Application”) as the lone parameter. At this<br />

point, when the code executes <strong>JMP</strong> starts.<br />

6. Call SetVisible(TRUE) on the <strong>JMP</strong> object created in step 5. If you do not want to see <strong>JMP</strong> execute, do not do<br />

this step. However, for debugging it is necessary.<br />

7. Now you can use the <strong>JMP</strong> application object to spawn further objects, which themselves can spawn more objects.<br />

The first thing you probably want to do is load a Data table. To load an existing <strong>JMP</strong> data table, call the<br />

OpenDocument method on the <strong>JMP</strong> object created in step 5. If successful, this method returns a dispatch pointer<br />

that can be attached to an object of type I<strong>JMP</strong>Doc using the AttachDispatch method.<br />

Page 9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!