I am trying to execute JSL files in a C#.NET wrapper. I am able to sucessfully run the files but my code does not wait for the script to finish. Below is a sample:
JMP.Application jmpInstance = new JMP.Application();
FileInfo fJSLFile = new FileInfo(@"C:\Test\Test.JSL");
jmpInstance.RunJSLFile(fJSLFile.ToString());
if (jmpInstance.HasRunCommandErrorString())
{
throw new ApplicationException("Error with JMP script: " + jmpInstance.GetRunCommandErrorString());
}
@gpuckett,
Were you able to figure this out ? I am looking to run JSL functions by passsing parameters to it from C#. Wondering if you could share any insight ?
Thank you for the snippet. I am trying to understand, where in your snippet are you invoking a function ?
TestPower = function({base,expn},{default local},
res = base ^ expn ;
Retrun(res);
);
Let us assume we have a user defined function in JMP like the one shown above. Now, starting from C#, how can I invoke this function by passing it parameters for base and exp and run this function ?
The snippet you shared addresses the part about how we can use the RunCommand function to pass a value, but can you use a simple example like this to explain the process a little more in detail ?
So, if i have the above function stored as TestPower.jsl on my C:\ , can you kindly share on how I would be able to run using C#, by passing it the parameters and calling this function ?
@ChrisM,
I actually managed to get it to run using your suggestion and a little luck of playing around. Here is my C# code that works.
// Create an instance of JMP and make it visible JMP.Application MyJMP; MyJMP = new JMP.Application(); MyJMP.Visible = true; MyJMP.ShowStartupWindow(); MyJMP.EnableInteractiveMode(true); // create command string arg1 = "base = 2"; // arguments to my User defined function in JSL string arg2 = "expn = 3"; // arguments to my User defined function in JSL MyJMP.RunCommand(arg1); MyJMP.RunCommand(arg2); string FilePathOfFileToRun = "C:\\Test.jsl"; MyJMP.RunJSLFile(FilePathOfFileToRun); // Running the user defined function // Needed to keep JMP from automatically closing JMP.DataTable dt = MyJMP.NewDataTable("test"); MyJMP.RunCommand(@"Close(Data Table(""test""), NoSave)");