cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
vince_faller
Super User (Alumni)

Exactly Recreate a new window() in its exact state

I'm creating a dynamic new window() with x amount of tabs and charts (other stuff).  Is there anything like Eval(dt << Get Script) that will recreate the window exactly?  Keeping all buttons functions fully intact and knowing where I was effectively.

Right now if I do it, I can't even get it to create using the eval(nw<<Get Script).

Edit*  Just to be clear.  I'm trying to recreate a window without knowing exactly what's inside of it. This is the example I came up with to show what I'm talking about:

Names default to here(14);

cwd = convert file path("./");

New window("Test",

       Hlistbox(

              tb = tabbox(

                           "Tab1",

                           Panelbox("Tab 1",

                           lb = listbox(filesindirectory("$SAMPLE_DATA")),

                           buttonbox("Open",

                                  file = (lb << Get Selected)[1];

                                  dt = Open("$SAMPLE_DATA\"||file)

                           )

                     ),

              )

       ),

       Hlistbox(

              Buttonbox("Back", tb<<Set Selected((tb << Get Selected)-1)),

              Buttonbox("Next",

                     newtab = Eval(other_boxes[(tb<<Get Selected)]);

                     tb<<Append("Tab", newtab);

                     tb<<Set Selected((tb<<GetSelected)+1)

              )

       )

);

other_boxes = {

       PanelBox("Blank, because ... reasons?"),

       PanelBox("Column Names",

              Collistbox(dt, all)

       )

      

};

It seems the general concensus is no.  So I'll just mark it as answered. 

Vince Faller - Predictum
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Exactly Recreate a new window() in its exact state

While JMP very nicely can create a script to recreate any individual platform, it does not carry that forward to user created display windows that are made up of those platforms.

The script below is a very simple example that illustrates that JMP DOES NOT create usable scripts from user defined display windows.

names default to here(1);

dt=open("$SAMPLE_DATA/Big Class.jmp");

nw=New Window("test",tab box("the script",

Bivariate( Y( :height ), X( :weight ) );

Distribution(

       Continuous Distribution(

              Column( :height ),

              Customize Summary Statistics( Mean( 0 ) )

       ),

       Continuous Distribution(

              Column( :weight ),

              Customize Summary Statistics( Mean( 0 ) )

       )

     );

   )

);

rr=nw<<get script;

show(rr);

  eval(rr);

Jim

View solution in original post

16 REPLIES 16
txnelson
Super User

Re: Exactly Recreate a new window() in its exact state

While JMP very nicely can create a script to recreate any individual platform, it does not carry that forward to user created display windows that are made up of those platforms.

The script below is a very simple example that illustrates that JMP DOES NOT create usable scripts from user defined display windows.

names default to here(1);

dt=open("$SAMPLE_DATA/Big Class.jmp");

nw=New Window("test",tab box("the script",

Bivariate( Y( :height ), X( :weight ) );

Distribution(

       Continuous Distribution(

              Column( :height ),

              Customize Summary Statistics( Mean( 0 ) )

       ),

       Continuous Distribution(

              Column( :weight ),

              Customize Summary Statistics( Mean( 0 ) )

       )

     );

   )

);

rr=nw<<get script;

show(rr);

  eval(rr);

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

Re: Exactly Recreate a new window() in its exact state

A Session Script will catch most features of your custom reports and interactive changes, including a compound report like in Jim's example. But it will also save code for recreating other windows and tables that you may not care about. 

You can save a session script at any time from the File menu.

It can also be set in the preferences to always save a session script when exiting JMP.

txnelson
Super User

Re: Exactly Recreate a new window() in its exact state

Unfortunately, "A Session Script will catch most features" does not appear to capture what Vince desires.  The dynamic Tab Boxes are not handled well.  In a modified version of my above script, I ran it, and then saved the session script, and then examined it.  The Tab Boxes are not carried forward to the Session Script.

Initial script

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/big class.jmp" );

New Window( "test", Tab Box( "tab 1", vlb = V List Box() ) );

If( Mod( Day( Today() ), 2 ) == 0,

       x1 = V List Box(

              Tab Box(

                     "Bivariate First",

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

                     dist = Distribution( Nominal Distribution( Column( :age ) ) )

              )

       ),

       x1 = V List Box(

              Tab Box(

                     "Distribution First",

                     dist = Distribution( Nominal Distribution( Column( :age ) ) ),

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

             

              )

       )

);

vlb << append( x1 );


The Session Script

Open( "C:\Program Files\SAS\JMPPRO\12\Samples\Data\Big Class.jmp", window bounds( 275, 484, 1288, 1141 ) );

New Window( "test",

       V List Box(

              Distribution( Nominal Distribution( Column( :age ) ) ),

              Bivariate( Y( :height ), X( :weight ) )

       )

) << Move Window( 722, 15 ) << Size Window( 488, 1025 ) << Set Window Icon( "ReportFile" );

Jim
vince_faller
Super User (Alumni)

Re: Exactly Recreate a new window() in its exact state

You'd be correct in that a session script isn't what I want.  If I try that, all it does is open the data table I have open.  It doesn't even try to create a new window().

Also, I tried the eval(nw<<Get Script) as well and it makes sense why it doesn't work, I was just hoping that there would be an easy solution rather than me having to recreate everything if I don't know what everything will be.

I'll keep hope alive a little while longer.

Just to clarify what I'm asking for:

box1 = PanelBox("1", teb = Text Edit Box("This is a test"), ButtonBox("Print", print(teb<<Get Text)));

box2 = PanelBox("2", teb = Text Edit Box("This is a test"), ButtonBox("Print", print((teb<<Get Text)||" Charlie")));

box3 = PanelBox("3", teb = Text Edit Box("This is a test"), ButtonBox("Print", print((teb<<Get Text)||" Susie")));

nw = New Window("Example",

      tb = TabBox()

);

stuff = Evallist({box1, box3});

for(i=1, i<=nitems(stuff), i++,

      tb<<Append(char(i), stuff)

);

nw<<Get Script

/* returns

V List Box(

      V List Box(

              Tab Box(

                    Tab Page Box(

                          Title( "1" ),

                          Panel Box( Text Edit Box( "This is a test" ), ButtonBox )

                    ),

                    Tab Page Box(

                          Title( "2" ),

                          Panel Box( Text Edit Box( "This is a test" ), ButtonBox )

                    )

              )

      )

)

*/


It doesn't have window title, or the scripts for the buttonbox.  Also, just won't run.

Vince Faller - Predictum
msharp
Super User (Alumni)

Re: Exactly Recreate a new window() in its exact state

I assume you created the dynamic window with a script.  In which case you could just have the button run the script again.

names default to here(1);

dt=open("$SAMPLE_DATA/Big Class.jmp");

nw=New Window("test",vlistbox("the script",

Bivariate( Y( :height ), X( :weight ) );

Distribution(

       Continuous Distribution(

              Column( :height ),

              Customize Summary Statistics( Mean( 0 ) )

       ),

       Continuous Distribution(

              Column( :weight ),

              Customize Summary Statistics( Mean( 0 ) )

       )

     );

     button box("Recreate Window",

              include("path\to\this\script\recreateWindow.jsl");

        )

   )

);

vince_faller
Super User (Alumni)

Re: Exactly Recreate a new window() in its exact state

I am creating it with a script but the user will choose what they want the window to look like (which data tables to open, etc).  And if I'm on tab(2) when I press save state, I want to be able to open back into save state, with tab(2) currently selected and all reports and tables open to the same position.  Right now I am creating (trying to create) a function to pull all of the relevant functions into a string and then just eval(parse())ing  it.  It leaves itself open to my mistakes a lot more than something simple like Eval(nw<<Get Script)

Vince Faller - Predictum
msharp
Super User (Alumni)

Re: Exactly Recreate a new window() in its exact state

I'm not sure what to tell you.  My solution recreates the window exactly, keeping all button functions fully intact and can know which tab you're on and everything asked for in the OP.

Plus, Eval(nw<<Get Script) isn't something simple b/c you know, IT DOESN"T WORK as shown by Jim Nelson.  The amount of coding to make it work would introduce larger amounts of mistakes, errors, and bugs then the simple solution I provided.

vince_faller
Super User (Alumni)

Re: Exactly Recreate a new window() in its exact state

My apologies, I must have stated my problem wrong.  This method doesn't work for me because user supplied information in tab 1 will be given to create tab 4 (or whatever tab).  If I just rerun the script, the user will have to go through the tabs 1-3 to get back to tab 4 where they were.  And the tabs aren't specified, they can be anything.  Right now I'm having to create a script that pulls in all the necessary functions and save that to a jsl (pretty similar to what you're saying except I have to create it on the fly), It's just slightly obfuscating is all.  I'll deal if there's not a better way.  Thank you.

Vince Faller - Predictum
msharp
Super User (Alumni)

Re: Exactly Recreate a new window() in its exact state

If you have something that works, I'm not going to push further.  But let me clarify on what you said above.

This METHOD does work for you because user supplied information in tab 1 will be given to create tab 4 (or whatever tab). 

If you just rerun the script, the user will have to go through the tabs 1-3 to get back to tab 4 where they were.  This is true, but this wouldn't be applying THE METHOD​, ​this would only be applying the example.


"Right now I'm having to create a script that pulls in all the necessary functions and save that to a jsl (pretty similar to what you're saying except I have to create it on the fly)." 

Why do you have to create it on the fly if it's already created? AKA, you have a script that can build it once, why build a second script to build it twice?