<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Script Run Sequentially in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Script-Run-Sequentially/m-p/483213#M72753</link>
    <description>&lt;P&gt;I am trying to create my Save Estimates from my survival platform, then grab the estimates in the newly created table. &amp;nbsp;The problem is that it will not wait until the Survival table is created before executing the Output expression. &amp;nbsp;I have tried finish, wait, different orders, etc... and I cannot get this to work, any suggestions? &amp;nbsp;I have JMP 16.0 with MacBook.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 0 );

Clear Log();

dt = Current Data Table();

If( Not( Is Scriptable( dt ) ),
	dtsel = Pick File( "Open File", {"JMP|jmp", "All files|*"} );
	If( dtsel == "",
		Stop(),
		Try( dt = Open( dtsel ), Stop() )
	);
);




Sur = Expr(
	Obj = dt &amp;lt;&amp;lt; Survival(
		Failure Plot( 1 ),
		Show Points( 1 ),
		Show Shaded Simultaneous CI( 1 ),
		Show Simultaneous CI( 1 ),
		Weibull Fit( 1 )
		//Save Estimates
	);
	dtname = Data Table( dt ) &amp;lt;&amp;lt; Get Name;
	Show( dtname );
	
	obj &amp;lt;&amp;lt; Save Estimates;
	wait(1);

);

Eval( Survival );

Output = Expr(
	dt2 = Data Table( dtname || " Survival");
	columnnamegroup = Column( dt2, 1 ) &amp;lt;&amp;lt; Get Name;
	Groups = Column( dt2, columnnamegroup ) &amp;lt;&amp;lt; Get As Matrix;
	Show( Groups );
		
);
Eval(Output);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 09 Jun 2023 16:58:08 GMT</pubDate>
    <dc:creator>lisamaley</dc:creator>
    <dc:date>2023-06-09T16:58:08Z</dc:date>
    <item>
      <title>Script Run Sequentially</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Run-Sequentially/m-p/483213#M72753</link>
      <description>&lt;P&gt;I am trying to create my Save Estimates from my survival platform, then grab the estimates in the newly created table. &amp;nbsp;The problem is that it will not wait until the Survival table is created before executing the Output expression. &amp;nbsp;I have tried finish, wait, different orders, etc... and I cannot get this to work, any suggestions? &amp;nbsp;I have JMP 16.0 with MacBook.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 0 );

Clear Log();

dt = Current Data Table();

If( Not( Is Scriptable( dt ) ),
	dtsel = Pick File( "Open File", {"JMP|jmp", "All files|*"} );
	If( dtsel == "",
		Stop(),
		Try( dt = Open( dtsel ), Stop() )
	);
);




Sur = Expr(
	Obj = dt &amp;lt;&amp;lt; Survival(
		Failure Plot( 1 ),
		Show Points( 1 ),
		Show Shaded Simultaneous CI( 1 ),
		Show Simultaneous CI( 1 ),
		Weibull Fit( 1 )
		//Save Estimates
	);
	dtname = Data Table( dt ) &amp;lt;&amp;lt; Get Name;
	Show( dtname );
	
	obj &amp;lt;&amp;lt; Save Estimates;
	wait(1);

);

Eval( Survival );

Output = Expr(
	dt2 = Data Table( dtname || " Survival");
	columnnamegroup = Column( dt2, 1 ) &amp;lt;&amp;lt; Get Name;
	Groups = Column( dt2, columnnamegroup ) &amp;lt;&amp;lt; Get As Matrix;
	Show( Groups );
		
);
Eval(Output);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:58:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Run-Sequentially/m-p/483213#M72753</guid>
      <dc:creator>lisamaley</dc:creator>
      <dc:date>2023-06-09T16:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Script Run Sequentially</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Run-Sequentially/m-p/483253#M72756</link>
      <description>&lt;P&gt;Are you getting any error message in JMP's log? In the example you gave have Sur name for expression and then evaluate Survival, not sure, could that be the issue? It should result in error like: Name Unresolved: Survival in access or evaluation of 'Survival' , Survival/*###*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This seems to work fine after changing then Eval(Survivor) -&amp;gt; Eval(Sur):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(0);

dt = Open("$SAMPLE_DATA/Rats.jmp");

Sur = Expr(
	obj = dt &amp;lt;&amp;lt; Survival(Y(:days), Censor(:Censor), Grouping(:Group));
	dtname = Data Table(dt) &amp;lt;&amp;lt; Get Name;
	obj &amp;lt;&amp;lt; Save Estimates;
);

Eval(Sur);

Output = Expr(
	dt2 = Data Table(dtname || " Survival");
	columnnamegroup = Column(dt2, 1) &amp;lt;&amp;lt; Get Name;
	Groups = Column(dt2, columnnamegroup) &amp;lt;&amp;lt; Get As Matrix;
	Show(Groups);
);
Eval(Output);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the fairly rare cases JMP requires adding some delay, wait(0) is usually enough (and if you have lots of formulas&amp;nbsp;&lt;EM&gt; &amp;lt;&amp;lt; run formulas &lt;/EM&gt;might help).&lt;/P&gt;</description>
      <pubDate>Sat, 30 Apr 2022 05:26:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Run-Sequentially/m-p/483253#M72756</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-04-30T05:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Script Run Sequentially</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Run-Sequentially/m-p/483254#M72757</link>
      <description>&lt;P&gt;I think I understand what you're trying to do -- effectively you want the input window for the &lt;CODE class=" language-jsl"&gt;Survival()&lt;/CODE&gt; platform to be &lt;CODE class=" language-jsl"&gt;Modal&lt;/CODE&gt; -- you want it to block execution of the script until the window is closed.&amp;nbsp; You can do that by explicitly defining a window instead of relying on the default behavior.&amp;nbsp; Here I've created a modal window that contains the input fields, then I grab each input and create the &lt;CODE class=" language-jsl"&gt;Survival()&lt;/CODE&gt; expression with the correct inputs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

If( Not( Is Scriptable( dt ) ),
	dtsel = Pick File( "Open File", {"JMP|jmp", "All files|*"} );
	If( dtsel == "",
		Stop(),
		Try( dt = Open( dtsel ), Stop() )
	);
);

dtname = Data Table( dt ) &amp;lt;&amp;lt; Get Name;
validated = 0;

New Window( "Inputs",
	&amp;lt;&amp;lt;Modal
,
	&amp;lt;&amp;lt;On Validate(
		survival = {};
		Insert Into( survival, Substitute( olb[List Box Box( 2 )] &amp;lt;&amp;lt; Get Items, {}, Expr( Y() ) ) );
		Insert Into( survival, Substitute( olb[List Box Box( 3 )] &amp;lt;&amp;lt; Get Items, {}, Expr( Grouping() ) ) );
		Insert Into( survival, Substitute( olb[List Box Box( 4 )] &amp;lt;&amp;lt; Get Items, {}, Expr( Censor() ) ) );
		Insert Into( survival, Substitute( olb[List Box Box( 5 )] &amp;lt;&amp;lt; Get Items, {}, Expr( Freq() ) ) );
		Insert Into( survival, Substitute( olb[List Box Box( 6 )] &amp;lt;&amp;lt; Get Items, {}, Expr( By() ) ) );
		Insert Into( survival, Insert( Expr( Censor Code() ), olb[Number Edit Box( 1 )] &amp;lt;&amp;lt; Get ) );
		Insert Into( survival, Insert( Expr( Plot failure instead of Survival() ), olb[Check Box Box( 1 )] &amp;lt;&amp;lt; Get ) );
		survival expr = Expr( Send( dt ) );
		Insert Into( survival expr, Substitute( survival, {}, Expr( Survival() ) ) );
		obj = survival expr;
		obj &amp;lt;&amp;lt; Save Estimates;
		validated = 1;
	)
,
	olb = Outline Box( "",
		dt &amp;lt;&amp;lt; Survival(
			Failure Plot( 1 ),
			Show Points( 1 ),
			Show Shaded Simultaneous CI( 1 ),
			Show Simultaneous CI( 1 ),
			Weibull Fit( 1 )
			//Save Estimates
		)
	)
);
If( !validated, Stop() );

dt2 = Data Table( dtname || " Survival");
columnnamegroup = Column( dt2, 1 ) &amp;lt;&amp;lt; Get Name;
Groups = Column( dt2, columnnamegroup ) &amp;lt;&amp;lt; Get As Matrix;
Show( Groups );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Apr 2022 06:01:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Run-Sequentially/m-p/483254#M72757</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2022-04-30T06:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: Script Run Sequentially</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Run-Sequentially/m-p/483262#M72760</link>
      <description>&lt;P&gt;That was a typo on my part, I had it correct before, but it did not work for me even when the two matched. &amp;nbsp; I tried the wait and it did not work. &amp;nbsp;I have no formulas, my entire script was copied.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Apr 2022 17:07:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Run-Sequentially/m-p/483262#M72760</guid>
      <dc:creator>lisamaley</dc:creator>
      <dc:date>2022-04-30T17:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: Script Run Sequentially</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Run-Sequentially/m-p/483263#M72761</link>
      <description>&lt;P&gt;Yes this works perfectly! &amp;nbsp;I have done modal windows in the past, but did not know how to do it with the platform. &amp;nbsp;I tried a few ways and failed. &amp;nbsp;I guess I did not think about just using a new window.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 30 Apr 2022 17:45:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Run-Sequentially/m-p/483263#M72761</guid>
      <dc:creator>lisamaley</dc:creator>
      <dc:date>2022-04-30T17:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Script Run Sequentially</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Run-Sequentially/m-p/483264#M72762</link>
      <description>&lt;P&gt;I much prefer &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/26363"&gt;@ErraticAttack&lt;/a&gt;'s solution but now that I understand the question correctly here is another method which might sometimes work. Setting On Close() to the platform window which will then execute whatever you want. This is quite error-prone due to depending on window names, but it could be made bit more robust, by comparing which windows exist before and after execution.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(0);

dt = Open("$SAMPLE_DATA/Rats.jmp");

Sur = Expr(
	obj = dt &amp;lt;&amp;lt; Survival();
	Window("Survival / Reliability") &amp;lt;&amp;lt; On Close(Output);
);
Eval(Sur);

Output = Expr(
	dtname = Data Table(dt) &amp;lt;&amp;lt; Get Name;
	For Each({window_name}, Get Window List() &amp;lt;&amp;lt; Get Window Title,
		If(Contains(window_name, Eval Insert("^dtname^ - Survival of ")),
			cur_w = Window(window_name);
			break();
		);
	);
	obj = cur_w[OutlineBox(1)] &amp;lt;&amp;lt; Get Scriptable Object;
	obj &amp;lt;&amp;lt; Save Estimates;
	dt2 = Data Table(dtname || " Survival");
	columnnamegroup = Column(dt2, 1) &amp;lt;&amp;lt; Get Name;
	Groups = Column(dt2, columnnamegroup) &amp;lt;&amp;lt; Get As Matrix;
	Show(Groups);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Apr 2022 19:15:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Run-Sequentially/m-p/483264#M72762</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-04-30T19:15:45Z</dc:date>
    </item>
  </channel>
</rss>

