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

How to modify an existing DisplayBox with JSL

I'm trying to create a button that will modify the output of the Fit Model() dialog to include a Predicted R2 in the Summary of Fit table.  I grab the current window and then I need to activate the PRESS statistic.  After this it's straightforward enough and it mostly works if I've already activated the PRESS statistic through the contest menu.  It also works if I code the Fit Model dialog myself and use line two to activate the PRESS statistic and then send it to the report.  The issue I'm running into is that grabbing the Current Window() grabs a DisplayBox with no way to instruct the platform to do things.  I considered just grabbing the script to make the window, closing the original and running a new one (one quick screen flicker isn't too bad) but the << Get Script returns the tree structure, not the Fit Model() script.  Is there something easy I'm missing?  I'm writing this in JMP 9, if that helps.  I'm hoping it is JMP 8 compatible, but that's not important.  Thanks!

dg = Current Window();

dg << PRESS; /###/

press = dg[NumberColBox("Press RMSE")] << Get as Matrix;

press = press[1];

ss = dg[NumberColBox("Sum of Squares")] << Get as Matrix;

lastrow = Nrow(ss);

sst = ss[lastrow];

predR = 1-press/sst;

values = dg[NumberColBox(1)] << Get as Matrix;

newvalues = J(1,6);

newvalues[1::2] = values[1::2];

newvalues[3] = predR;

newvalues[4::6] = values[3::5];

dg[StringColBox(1)] << Set Values({"RSquare","RSquare Adj","RSquare Pred","Root Mean Square Error","Mean of Response","Observations (or Sum Wgts)"});

dg[NumberColBox(1)] << Set Values(newvalues);

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: How to modify an existing DisplayBox with JSL

Ok, I see. The reason that <<get script gives a "tree" is that a display box is adressed rather than the fit-least-squares run (or whatever it's called) object. At least I think so.

I took me a while to figure out, but the approach below, using <<get scriptable object, seems to correctly identify the actual analysis top object within a report window done by hand. It should work for simple report windows, but for windows with multiple top level outlines, for example when using "group", it may not work without further thought.

dt = Open( "$ENGLISH_SAMPLE_DATA/Big Class.jmp" );

Fit Model(

          Y( :weight ),

          Effects( :height ),

          Personality( Standard Least Squares ),

          Emphasis( Minimal report ),Run

          );

fit=Window("Big Class: Fit Least Squares")[outlinebox(1)]<<get scriptable object;

fit<<Press(1);

print(fit<<get script) //Get Script works as expected!

View solution in original post

6 REPLIES 6

How to modify an existing DisplayBox with JSL

Just to be clear, the first line, dg = Current Window(); returns DisplayBox[] in the log.  I'm looking for a way to access context menus in the window via JSL to add things to the Tree Structure so I can grab them later on, specifically, how to flag PRESS(1).  Thanks!

ms
Super User (Alumni) ms
Super User (Alumni)

How to modify an existing DisplayBox with JSL

I am not sure exactly what you are trying to do, but I think you must send the Press(1) message to a Fit Model object rather than to a Window object. As in the example below (Run and then click "PRESS"). Works in JMP9 (Mac).

dt = Open( "$English_Sample_Data/Tiretread.jmp" );

fit = Fit Model(

          Y( :ABRASION ),

          Effects( :SILICA, :SILANE ),

          Personality( Standard Least Squares ),

          Emphasis( Minimal Report ),

          Run(

                    :ABRASION << {Plot Actual by Predicted( 0 ), Plot Regression( 0 ), Plot Residual by Predicted( 0 ),

                    Plot Effect Leverage( 0 )}

          )

);

dg = Report( fit );

dg << prepend(

  Button Box( "PRESS",

                    fit << press( 1 );

                    press = dg[Number Col Box( "Press RMSE" )] << Get as Matrix;

                    press = press[1];

                    ss = dg[Number Col Box( "Sum of Squares" )] << Get as Matrix;

                    lastrow = N Row( ss );

                    sst = ss[lastrow];

                    predR = 1 - press / sst;

                    values = dg[Number Col Box( 1 )] << Get as Matrix;

                    newvalues = J( 1, 6 );

                    newvalues[1 :: 2] = values[1 :: 2];

                    newvalues[6] = predR;

                    newvalues[3 :: 5] = values[3 :: 5];

                    dg[String Col Box( 1 )] << Add Element( "RSquare Pred" );// Add Values does not work, hence the reordering

                    dg[Number Col Box( 1 )] << Set Values( newvalues );

          )

);


How to modify an existing DisplayBox with JSL

MS - thanks for your quick reply!  The issue is that for this to deploy the way I want it to, it cannot include the portion below.

fit = Fit Model(

          Y( :ABRASION ),

          Effects( :SILICA, :SILANE ),

          Personality( Standard Least Squares ),

          Emphasis( Minimal Report ),

          Run(

                    :ABRASION << {Plot Actual by Predicted( 0 ), Plot Regression( 0 ), Plot Residual by Predicted( 0 ),

                    Plot Effect Leverage( 0 )}

          )

);

dg = Report( fit );


I want to be able to deploy this as an addin for end-users to simply be able to press from their toolbar after having fit a model using the typical JMP interface and have it append the important information.

What confuses me is that I cannot, via JSL, access the context menu of the window if JMP created it rather than JSL creating it.  I can access the top-level menus via JSL easily, but not the context menu.  Also, I don't understand why the << Get Script message returns the tree structure of the window rather than a JSL script to create it like what the context menu provides.  I know that JMP can do the things I want, I just seem to be locked of them from JSL.

ms
Super User (Alumni) ms
Super User (Alumni)

Re: How to modify an existing DisplayBox with JSL

Ok, I see. The reason that <<get script gives a "tree" is that a display box is adressed rather than the fit-least-squares run (or whatever it's called) object. At least I think so.

I took me a while to figure out, but the approach below, using <<get scriptable object, seems to correctly identify the actual analysis top object within a report window done by hand. It should work for simple report windows, but for windows with multiple top level outlines, for example when using "group", it may not work without further thought.

dt = Open( "$ENGLISH_SAMPLE_DATA/Big Class.jmp" );

Fit Model(

          Y( :weight ),

          Effects( :height ),

          Personality( Standard Least Squares ),

          Emphasis( Minimal report ),Run

          );

fit=Window("Big Class: Fit Least Squares")[outlinebox(1)]<<get scriptable object;

fit<<Press(1);

print(fit<<get script) //Get Script works as expected!

Re: How to modify an existing DisplayBox with JSL

MS - the Get Scriptable Object solves the problem perfectly!  I do see where having 'group' could cause problems, but I don't think that will be a real issue given the type of work that we do here.  Thank you very much for leading me to the solution!

dg = Current Window();

fm = dg[OutlineBox(1)] << Get Scriptable Object;

fm << PRESS(1);

press = dg[NumberColBox("Press")] << Get as Matrix;

press = press[1];

ss = dg[NumberColBox("Sum of Squares")] << Get as Matrix;

lastrow = Nrow(ss);

sst = ss[lastrow];

SpannerHead
Level IV

Re: How to modify an existing DisplayBox with JSL

I was trying to devise a script to save the script to the script window for an open Fit Group window.  A script to grab a script in other words.  To do this I need to make the Fit Group and object and send a message to it.  Easy to do manually, is that possible to automate?


Slán



SpannerHead