The above JSL script creates six graphics files "on the fly", as well as a text file of P3ICLI commands (stored in p3icli_script.txt). The text file is passed to P3ICLI's command line via the JSL "RunProgram" command, using this syntax (specific to JMP v11 and later):/* 1: Open a data set provided by JMP 2: Create several individual graphs, trying to maintain the same size, and store in C:\temp 3: Create a "By analysis" and count and save each one. // at this point use P3I or continue with the script to automatically create PPT 4: Create commands for p3icli 5: Save the text box as a p3icli text file 6: Run it. 7: Clean up JMP */ //1: Open a data set provided by JMP dt = open("$sample_data\Iris.jmp"); Column(dt,"Species") << Label(1); //2: Create several individual graphs, trying to maintain the same size. // Store graphs in C:\temp pp = dt << Parallel Plot( Y( :Sepal length, :Sepal width, :Petal length, :Petal width, :Species ), SendToReport( Dispatch( {}, "Parallel Coord", FrameBox, {Frame Size( 419, 246 )} ) ) ); //customize dt << select rows([44,78,101]); dt<< label; dt<< clear select; report(pp)[Outline Box(1)] << set title("Parallel Plot - Look for Patterns"); report(pp)[OutlineBox(1)] << save picture("c:\temp\sample_pp.png"); spm = dt << Scatterplot Matrix( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Matrix Format( "Lower Triangular" ), Ellipse Color( 3 ), SendToReport( Dispatch( {}, "Scatterplot Matrix Options", FrameBox, {Frame Size( 62, 56 )} ) ) ); report(spm)[OutlineBox(1)] << save picture("c:\temp\sample_spm.png"); //oneway for each response onew = dt << Oneway( Y( :Sepal length, :Sepal Width, :Petal Length, :Petal Width ), X( :Species ), Means and Std Dev( 1 ), Box Plots( 1 ), Mean Error Bars( 0 ), Std Dev Lines( ), X Axis Proportional( 0 ), Points Jittered( 1 ), ); for(i=1, i <=nitems(onew), i++, report(onew[i]) << save picture(Eval Insert("c:\temp\sample_ow^i^.png")); ); //at this point there are 6 graphs in c:\temp and you can use p3i to view or... // commands to create a p3icli script are stored in a list //================================================================== cmdList = {}; Insert Into( cmdList, "#commands" ); Insert Into( cmdList, "kill ppt save" ); Insert Into( cmdList, "sleep 500" ); Insert Into( cmdList, "copy source format on" ); //keep the background formatting //you can call up different slides from different templates...just specify //which slide and the template path Insert Into( cmdList, "insert slide 1 from template c:\temp\sample_jsl_template.ppt" ); Insert Into( cmdList, "\[title " Iris Data Set Analysis"]\" ); Insert Into( cmdList, "insert slide 3 from template c:\temp\sample_jsl_template.ppt" ); Insert Into( cmdList, "\[title " Iris Data - Correlation Plots"]\" ); Insert Into( cmdList,"pic1 c:\temp\sample_pp.png" ); Insert Into( cmdList, "pic2 c:\temp\sample_spm.png" ); Insert Into( cmdList, "insert slide 2 from template c:\temp\sample_jsl_template.ppt" ); Insert Into( cmdList, "\[title " Iris Data - Oneway Plots"]\" ); //note 4 pics and 4 graphs...if more than 4 graphs, insert a new template. for(i=1, i<=nitems(onew), i++, Insert Into( cmdList, EvalInsert("pic^i^ c:\temp\sample_ow^i^.png" ) ); ); Insert Into( cmdList, "sleep 500" ); Insert Into( cmdList, "save as presentation c:\temp\p3icli_jmp_jsl_results.ppt" ); Insert Into( cmdList,"sleep 500" ); Insert Into( cmdList, "kill ppt save" ); // Concatenate commands with \!N line break chars appropriate for the host environment xtxt = Concat Items(cmdList,"\!N"); Save Text File( "c:\temp\p3icli_script.txt" , xtxt); wait(2); //p3icli_script.txt has all the commands above with the proper names. //JMP 11 includes a command (RunProgram) that runs an executable. Past versions //of JMP required a .bat file that was executed via the JSL web() command //RunProgram can be invoked in synchronous or asynchronous mode. In asynchronous //mode, JMP scripting continues as soon as the external program is launched. For //our purposes, that behavior is unnecessarily complex. In synchronous mode, JMP //scripting is suspended until the external program exits (finishes its tasks). //We want the synchronous behavior. //To force synchronous behavior, simply add a ReadFunction() argument to //RunProgram, which forces JMP to continually "listen" for executable output //and stop listening when the external program completes. rpobj = RunProgram(Executable("p3icli" ), Options("-l c:\temp\log.txt c:\temp\p3icli_script.txt"), ReadFunction("text") // force synchronous mode ); //Clean up JMP files pp<<close Window(); spm << close window(); onew<<close window(); close(dt, NoSave); /* * For more information about JSL see: * * JSL Companion: Applications of the JMP(R) Scrpting Language * * by Utlaut, Theresa L., Georgia Z. Morgan, and Kevin C. Anderson, 2011, * Cary, NC:SAS Institute Inc. */
Herewith, the contents of p3icli_script.txt:RunProgram(Executable("p3icli" ), Options("-l c:\temp\log.txt c:\temp\p3icli_script.txt"), ReadFunction("text")
#commands kill ppt save sleep 500 copy source format on insert slide 1 from template c:\temp\sample_jsl_template.ppt title " Iris Data Set Analysis" insert slide 3 from template c:\temp\sample_jsl_template.ppt title " Iris Data - Correlation Plots" pic1 c:\temp\sample_pp.png pic2 c:\temp\sample_spm.png insert slide 2 from template c:\temp\sample_jsl_template.ppt title " Iris Data - Oneway Plots" pic1 c:\temp\sample_ow1.png pic2 c:\temp\sample_ow2.png pic3 c:\temp\sample_ow3.png pic4 c:\temp\sample_ow4.png sleep 500 save as presentation c:\temp\p3icli_jmp_jsl_results.ppt sleep 500 kill ppt save