cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
SDF1
Super User

JSL help with proper reference to a report

Hi All,

 

  I'm having difficulty with the proper referencing of a report when trying to send to the report the command <<Save Simulation Formula. 

 

  I have an automated script to perform certain analyses, and in this script, I get a list of the open reports to obtain the report_of_interest, see JSL below:

 

report_windows = Get Window List( "Report" );
report_of_interest = Empty();
For Each( {report_windows}, report_windows,
	outline_title = Try( report_windows[Outline Box( 1 )] << Get Title, "" );
	If( Starts With( outline_title, "Generalized " ),
		report_of_interest = report_windows;
		Break();
	);
);

  The report_of_interest is a reference to the DisplayBox[HeadBox] of the report. Using this reference, I can do things like send the command to perform a simulation of a column of interest in the report, for example parameter estimate column.

report_of_interest[Number Col Box( 8 )] << Simulate(
	2500,
	Random Seed(.),
	Out( :ColOut ),
	In( :ColIn )
);

  However, when I try to send the command <<Save Simulation Formula to the report_of_interest (following the example in the Scripting Index Help):

report_of_interest << (Fit[1] << Save Simulation Formula)

  I get the following error in the log window:

 

Object 'HeadBox' does not recognize the message 'Send'; perhaps you mean one of these: <<Sib Append <<Append <<Set Dirty <<Paste <<Set Window Title <<Sib Prepend <<Prepend <<Find <<Save PDF <<Save MSWord <<Set Window Size <<Set Window ID <<Size Window <<Move Window <<Show Window <<Close Window <<Set Window Title <<Set Window Icon <<Set Main Window <<Set Print Headers <<Mouse Drag <<Set Min Size <<Set Width <<Enabled.

 

  If I try to use the title of the outline, the variable outline_title from above, I get the following error in the log:

Send Expects Scriptable Object in access or evaluation of 'Send' , outline_title << /*###*/(Fit[1] << Save Simulation Formula) /*###*/

 

  What I don't understand is the difference in the reference to the examples in the Scripting Index help vs my JSL code. From the first example in the Scripting Index help is the following:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Diabetes.jmp" );
fm = dt << Fit Model(
	Y( :Y ),
	Effects( :Age, :Gender, :BMI, :BP, :Total Cholesterol, :LDL, :HDL, :TCH, :LTG, :Glucose ),
	Personality( "Generalized Regression" ),
	Generalized Distribution( "Normal" ),
	Run( Fit( Estimation Method( Lasso( Adaptive ) ), Validation Method( KFold, 5 ) ) )
);
fm << (fit[1] << Save Simulation Formula);

  The fm is a variable that references the following: Fit Generalized[]. In the Scripting Index examples, they are all able to save the simulation column to the data table using this reference.

 

  One big difference that I can see, is in the examples, they're all able to send to the data table the Fit Model () command with the sub command Run(Fit()). I can't do that in my JSL code as it is more generalized and I'm not always running it on the same columns for the Y, Response and X, Factors.

 

  The analogous JSL in my code is the following:

avdt << Fit Model(
	Y( Eval( YCols ) ), 
	Validation( :Validation ),
	Personality( "Generalized Regression" )
);

  Note that I don't have any Effects listed because these can change depending on the data table that I'm working with. I do have a section of code before that asks to indicate which column is the response column, and therefore, I can include the Y(Eval(ycols)) in the Fit Model() because the JSCL code has a reference to that column.

 

  Unfortunately, I can't do anything like fm = avdt << Fit Model(), and reference it that way because once I enter all the effects and click Run on the GenReg platform window, fm returns the error that it is a deleted object reference[]. In fact if you comment out the line with Run() in the example from the Scripting Index help, and run it, click Run in the Fit Model dialogue, the example code will not save the simulation column to the data table.

 

  Sorry for the long post, but I felt I needed to put some context behind the issue I'm having. Any help on correcting the proper referencing of the report_of_interest, so I can send the <<Save Prediction Formula would be much appreciated.

 

Thanks!,

DS

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: JSL help with proper reference to a report

One difference is that you are using different references, scripting index example is using "Fit Generalized[]" and you are using "DisplayBox[HeadBox]". You can most likely get reference to Fit Generalized by using something like

report_of_interest[OutlineBox(1)] << get scriptable object;
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: JSL help with proper reference to a report

One difference is that you are using different references, scripting index example is using "Fit Generalized[]" and you are using "DisplayBox[HeadBox]". You can most likely get reference to Fit Generalized by using something like

report_of_interest[OutlineBox(1)] << get scriptable object;
-Jarmo
SDF1
Super User

Re: JSL help with proper reference to a report

Hi @jthi ,

 

  Thanks, as always, for your quick and helpful response! Yes, that does work. I also realized I could get around this by changing an earlier part of my code where it requests the response column to be modeled, so that it also asks for the model effects at the same time. This way, I could include the fm = dt<<Fit Model(Run()), and it works just fine.

 

  I haven't had to use the << Get Scriptable Object often, so it's not a command that really comes to mind. I appreciate the help.

 

Thanks!,

DS