cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
pjr1121
Level II

Remotely run JSL script with parameters

Hello,

 

We currently have a JMP script which we run for data analysis/reporting.  I would like to trigger this script at the end of data acquisition (LabVIEW via ActiveX).  I've located the RunJSLFile function but it only has the filepath as an input.

 

How can I implement passing a parameter to JMP for use in the script (a string which identifies the part number)?  Do I need to use RunCommand to create a global variable which is then utilized by the script?  If so, what would the command look like?

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Remotely run JSL script with parameters

PS: If you have access to the RunCommand from within labview/ActiveX, you can skip the vbs file entirely and put that code into your existing application.

View solution in original post

7 REPLIES 7
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Remotely run JSL script with parameters

I am sure someone else can do this more elegantly but here is one method using vbscript.

 

Paste this into a .vbs file on a windows computer.

'Create the JMP application object
set jmp = Wscript.CreateObject("JMP.Application")

'Open a data table that already contains your script
set jmpdoc = jmp.OpenDocument("C:/test.jmp")

'Make it visible for demo
jmpdoc.Visible = True

'Set a table variable to be your 'parameter'
jmp.RunCommand("current data table() << Set Table Variable( ""input"", 20); ")


'Run the script
jmp.RunCommand("eval(Current Data Table() << Get Table Property( ""add Column"" ));")

 

 

Then make a data table called test.jmp in your C drive with a saved script called "add Column" that contains this:

dt = current data table();
val = dt << Get Table Variable("input");
New Column( "Column 2",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Values( {val, val, val} )
	);

 

Double click the vbs file and you should see a new column with three rows set to 20.

pjr1121
Level II

Re: Remotely run JSL script with parameters

This looks like a viable approach and would work great for tables which contain data to be analized.  This application is slightly different as we a processing data which is stored outside of JMP (SQL database).  I could create a table to contain the script (essentially a wrapper), but I think there should be a better approach for this application.

 

The script in question is NOT contained in a table currently.  It is a stand-alone *.jsl file which contains custom written functions to load data from various SQL queries, generate multple tables and graphs, and then collect the graphs in a  journal.

 

if I do   jmp.RunCommand("ID = "12345";")   , will this create a global variable that can be seen by the script.. run via

jmp.RunJSLFile("<path to JSL file>")    which utilizes ::ID  within various functions?

ih
Super User (Alumni) ih
Super User (Alumni)

Re: Remotely run JSL script with parameters

You could include a 'main' function in your JSL script, include it in a JMP session called by a vbscript, and then call the main function in your script with arguments.  Here is an example:

 

.vbs file:

'Create the JMP application object
set jmp = Wscript.CreateObject("JMP.Application")

'read the existing jsl script
jmp.RunCommand("include( ""C:/ScriptWithParam.jsl"" );")

'set parameter values
param1 = "some value"

'Run a function inside the script
jmp.RunCommand("MakeTable( """ & param1 & """ );")

 

JSL file:

MakeTable = function({param1 = "2"},
	result = 1;
	colvalues = {"Your value was",Char(param1)};
	colvalues = Eval List(colvalues);
	New Table( "test",
		Add Rows( 2 ),
		New Column( "Column 1",
			Character,
			"Nominal",
			Set Values( colvalues )
		)
	);
	show(param1);
	result = 0;
	Return(result);
);
Craige_Hales
Super User

Re: Remotely run JSL script with parameters

pjr1121
Level II

Re: Remotely run JSL script with parameters

Yes, there is some documentation regarding OLE automation, and I've read through most of it.  While helpful, for general tasks, such as launching a .jmp file, it seems lacking in regards to the vast posibilities of interfacing with other programs.  Is there more detailed documentation somewhere?

 

For instance, can I remotely launch a JMP script from a computer (which does not have JMP installed) via network access to a computer which does have JMP installed?  Or does it need somefiles which are part of the JMP installation (such as jmp.tlb)?.

txnelson
Super User

Re: Remotely run JSL script with parameters

Your question has a couple of dimensions to it.  The first is the issue of remotely starting JMP, the second one, is a legal issue.  There are ways to fire off a JMP session on a remote computer.  Most of that would be handled by OS functionality, and it's relationship to the application program you have written.

The second one, is a question of licensing. You need to make sure that each person running this remote JMP session is covered by your license agreement to be authorized/licensed to run JMP. 

Jim
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Remotely run JSL script with parameters

PS: If you have access to the RunCommand from within labview/ActiveX, you can skip the vbs file entirely and put that code into your existing application.