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
robot
Level VI

JSL Retrieve Selected Frame Box

Hi,

I am trying to create a JMP script that will add a graphics script to a pre-existing platform, based on some user selection.  How can I retrieve the reference to a user-selected frame box?  Is there a better way to do this?  I am using JMP10.

Thanks!

Names Default To Here( 1 );

// Example.

bigClass = Open( "$SAMPLE_DATA/Big Class.jmp" );

biv = bigClass << Bivariate( Y( :weight ), X( :height ) );

// User will select one or many frame boxes.

rbiv = biv << Report;

sel = rbiv[FrameBox( 1 )];

sel << Select;

// Help needed:

// JMP will retrieve the reference to the selected frame box and add a graphics script.

// JMP will add something to selected frame box...

sel << Add Graphics Script(Text( Center Justified, {55, 160}, "Hi!" ););

sel << Deselect; // JMP will return graph to user.

7 REPLIES 7
pmroz
Super User

Re: JSL Retrieve Selected Frame Box

Instead of going the report route and digging through the tree structure, you could also just create a window and add whatever you want to it.  For example:

Names Default To Here( 1 );

// Example.

bigClass = Open( "$SAMPLE_DATA/Big Class.jmp" );

nw = new window("Example",

     biv = bigClass << Bivariate( Y( :weight ), X( :height ) ),

     tb = Textbox( "Hi!" )

);

tb << set width(500);

tb << Justify Text( center );

robot
Level VI

Re: JSL Retrieve Selected Frame Box

Hi PMroz,

Thank you the the input.  If possible, I would like to edit the graphics script after the graph has been created.  It it possible to retrieve the reference to a selected frame box?

pmroz
Super User

Re: JSL Retrieve Selected Frame Box

Yes.  You can add this statement to the code above:

nw << show tree structure;

Which will produce the tree structure output.  You can browse this for the necessary frame box.

10093_Tree Structure nw.png

robot
Level VI

Re: JSL Retrieve Selected Frame Box

Hi PMroz,

Sorry for not being clear.

I am trying to create a JMP Add-In that will allow the user to add a preset graphics script to a chart that s/he has already created.  The graphics script may be needed for many different chart types, so is not practical to create a full script for the graph and include the graphics part; the number of options needed are too many.  Also, the end user may not have the familiarity with JMP needed to manipulate the tree structure.

I hope to have the user select a frame box using the Selection Tool, and then run the Add-In to add the graphics script.  The missing piece to my puzzle is to get JMP to detect the frame box the user has selected.  Once I have the frame box reference, I can then add the graphics. 

Is it possible for JMP to detect which frame box (or graph) has been selected?

As a last-resort, I can ask the end user to add the graphics script manually using the Customize Graph properties, but I hope for a more elegant solution.

robot
Level VI

Re: JSL Retrieve Selected Frame Box

I am able to select the current window and show a tree structure, but I am unable to access the frame boxes within it.  An example is below.  Any ideas?

// Example.

Names Default To Here( 1 );

// Run this entire JSL block at once, from here...

bigClass = Open( "$SAMPLE_DATA/Big Class.jmp" );

biv = bigClass << Bivariate( Y( :weight ), X( :height ) );

Wait( 2 );

win = Current Window();

// ...to here.

// Add text to biv.

biv << Show Tree Structure;

rbiv = biv << Report;

sel = rbiv[FrameBox( 1 )];

sel << Select; // User will select one or many frame boxes.

sel << Add Graphics Script( "Back", Text( Center Justified, {55, 160}, "Hi!" ) ); // Add script.

sel << Deselect;

// Try to select win.

win << Show Tree Structure; // This works.

rwin = win << Report;

selwin = rwin[FrameBox( 1 )];

selwin << Select; // This does not work.  Why not?

selwin << Deselect;

ian_jmp
Level X

Re: JSL Retrieve Selected Frame Box

You don't need 'rwin' since 'win' is already a report. So the last few lines should be:

// Select win.

win << Show Tree Structure; // This works.

selwin = win[FrameBox( 1 )];

selwin << Select;

Wait( 2 );

selwin << Deselect;

robot
Level VI

Re: JSL Retrieve Selected Frame Box

Thanks Ian.