<?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 Re: JSL - Why do I get error first time running script, but second time onward works? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/360612#M61010</link>
    <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/15193"&gt;@adjo9835&lt;/a&gt;&amp;nbsp;Did you find the problem? I am getting this error too with a variable, only on the first run but not the second. I am using JMP 15&lt;/P&gt;</description>
    <pubDate>Thu, 18 Feb 2021 20:58:16 GMT</pubDate>
    <dc:creator>Jazib</dc:creator>
    <dc:date>2021-02-18T20:58:16Z</dc:date>
    <item>
      <title>JSL - Why do I get error first time running script, but second time onward works?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/215045#M42993</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: Arial,Helvetica,sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 27.42px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;The first time running the script shown below returns this error "Name Unresolved: m{36803} in access or evaluation of 'm', m/*###*/", while every subsequent run does not return that error.&amp;nbsp; Why is this?&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;DataCV=open("C:\Desktop\JMP\sample_CV_data.csv"); 
Summarize( DataCV, processArray = By( :process ) );
Summarize( DataCV, ctypeArray = By( :c_type ) );

For( n = 1, n &amp;lt;= Length( ctypeArray ), n++,		// Generates and saves all splines by :c_type and :process
	For( m = 1, m &amp;lt;= Length( processArray ), m++,
		Eval(
			Substitute(
					Expr(
						biv = Bivariate(
							Y( :c_mm_deembed_pf ),
							X( :v_dut_volt ),
							Where( :c_type == __ctype__ &amp;amp; :process == __process__ ),
							Fit Spline( 0.1, standardized, {save predicteds} )	
						)
					),
				Expr( __process__ ), processArray[m],
				Expr( __ctype__ ), ctypeArray[n],
			)
		)
	);
);

(Data Table( DataCV ) &amp;lt;&amp;lt; Tabulate(	// Create new table
       Add Table(
              Column Table( Analysis Columns( :Spline Predictor for c_mm_deembed_pf Where ) ),
              Row Table( Grouping Columns(:serial_num, :process, :c_type, :v_dut_volt ) )
       )
)) &amp;lt;&amp;lt; Make Into Data Table;

currentDataTable()&amp;lt;&amp;lt;AddRows(1);	// Add an empty last row so while loop knows when its at the end

q = 0;
proc = "new";
i = 1;
while(q == 0,			// Delete redundant splines (:process x :c_type combinations)
	if (proc != (Row()=i;:process), 
		proc = (Row()=i;:process); sn = (Row()=i;:serial_num); i+=1
	);
	if (proc == (Row()=i;:process) &amp;amp; sn == (Row()=i;:serial_num),					
		i+=1	
	);				
	if (proc == (Row()=i;:process) &amp;amp; sn != (Row()=i;:serial_num),	
		CurrentDataTable()&amp;lt;&amp;lt;DeleteRows(i) 
	);
	if ((Row()=i;:process) == "",
		q = 1;
	);
);

currentDataTable() &amp;lt;&amp;lt; Delete Rows(i);	// Delete empty last row
currentDataTable() &amp;lt;&amp;lt; new column("Index", character);

cap = "new";
for (k = 1, k&amp;lt;=NRows(currentDataTable()), k++,	// Add VARs for ADS indexing
	if (cap != :c_type[k], 
		currentDataTable() &amp;lt;&amp;lt; Add Rows(1, k-1); j=1; cap = :c_type[k+1]; proc = :process[k+1]
	);
	if (j==1,
		For Each Row(:Index = if(:c_type=="", 
					"\!NVAR CURVE(1) = " || char(cap) || "\!NVAR TECH(1) = " || char(proc) || "\!NBEGIN\!N% ind(1)	dep(1)", 
					:Index));
		For Each Row(:c_type = if(:c_type=="", 
					char(cap), 
					:c_type)); j=0
	);
);


currentDataTable() &amp;lt;&amp;lt; delete columns("c_type", "serial_num", "process");	// Delete all rows except for ind(1) and dep(1)

xptPref = Get Preferences( Export Settings );	// .MDF format
Preferences(
	ExportSettings(
		End Of Line( CRLF ),
		End Of Field( Tab ),
		Export Table Headers( 0 )
	)
);

currentDataTable () &amp;lt;&amp;lt; Save As( "C:\JMP\GeneratedFiles\RoughDraft2Output.mdf", "text" );	// Save as .MDF&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 19:31:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/215045#M42993</guid>
      <dc:creator>adjo9835</dc:creator>
      <dc:date>2019-06-27T19:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: JSL - Why do I get error first time running script, but second time onward works?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/215090#M43000</link>
      <description>&lt;P&gt;Try something like this for a start. Is the error in that Eval? Does the table have a column named "m"?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( m = 1, m &amp;lt;= Length( processArray ), m++,
	show(m,processArray[m]); // &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; 
	Eval(&amp;nbsp;...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can further isolate what's happening with an intermediate variable to hold (and print the nameexpr) the result of substitute.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 19:30:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/215090#M43000</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2019-06-27T19:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: JSL - Why do I get error first time running script, but second time onward works?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/215121#M43004</link>
      <description>&lt;P&gt;Adding:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;show(m,processArray[m]);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to the script results in the log showing:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;m = 1;
processArray[m] = "DVT0002B";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;therefore, the error must be inside of the Eval()?&lt;/P&gt;&lt;P&gt;The data table has no columns named "m".&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 21:18:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/215121#M43004</guid>
      <dc:creator>adjo9835</dc:creator>
      <dc:date>2019-06-27T21:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: JSL - Why do I get error first time running script, but second time onward works?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/215323#M43027</link>
      <description>&lt;P&gt;Pretty cool script!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this version&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;DataCV = Open( "$sample_data/big class.jmp" );
Summarize( DataCV, processArray = By( :age ) );
Summarize( DataCV, ctypeArray = By( :sex ) );

For( n = 1, n &amp;lt;= Length( ctypeArray ), n++,
    Show( n, ctypeArray[n] );
    For( m = 1, m &amp;lt;= Length( processArray ), m++,
        Show( m, processArray[m] );
        temp = Substitute(
                Expr(
                    biv = Bivariate(
                        Y( :height ),
                        X( :weight ),
                        Where( :sex == __ctype__ &amp;amp; :age == Num( __process__ ) ),
                        Fit Spline( 0.1, standardized, {save predicteds} )
                    )
                ),
            Expr( __process__ ), processArray[m],
            Expr( __ctype__ ), ctypeArray[n],

        );
        Show( Name Expr( temp ) );
        Eval( temp );
    );
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Other than the change to a sample script and adding the NUM() wrapper and printing the intermediate expression, I don't think I've changed anything. In JMP 14, I don't see the error you describe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like the summary of the numeric age column made a list of strings rather than numbers, so num converts it back. I don't think this is part of the original problem you described.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11257"&gt;@EvanMcCorkle&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2019 10:45:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/215323#M43027</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2019-06-28T10:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: JSL - Why do I get error first time running script, but second time onward works?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/215429#M43047</link>
      <description>&lt;P&gt;Thanks! I feel pretty good about it considering this is my first time using JMP and that file conversion isnt a typical JMP application.&lt;/P&gt;&lt;P&gt;Im still getting the same error, only on the first time running the script, shown below.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 700px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/18067i64B3F92E23F81D06/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The script even generates and saves one of the splines from one of the :c_type x :process Where-clause combinations, into a new column, before throwing the error.&amp;nbsp; Implying that it went through one full iteration of the for loop shown below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( n = 1, n &amp;lt;= Length( ctypeArray ), n++,&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The 1 spline that was created and saved into a new column is shown below:&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/18068iB3943F9D0248E973/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am going to try and update to JMP 14, to see if that solves the problem.&amp;nbsp; I have been using JMP 13.0.0&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2019 17:57:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/215429#M43047</guid>
      <dc:creator>adjo9835</dc:creator>
      <dc:date>2019-06-28T17:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: JSL - Why do I get error first time running script, but second time onward works?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/360612#M61010</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/15193"&gt;@adjo9835&lt;/a&gt;&amp;nbsp;Did you find the problem? I am getting this error too with a variable, only on the first run but not the second. I am using JMP 15&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 20:58:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/360612#M61010</guid>
      <dc:creator>Jazib</dc:creator>
      <dc:date>2021-02-18T20:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: JSL - Why do I get error first time running script, but second time onward works?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/362253#M61199</link>
      <description>&lt;P&gt;Have you tried throwing in a&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Names default to here(1);&lt;/PRE&gt;&lt;P&gt;at the beginning of your script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your variable m might be defined by another script and it could be interfering here untill it is overwritten for the first time by this script.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 16:30:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Why-do-I-get-error-first-time-running-script-but-second-time/m-p/362253#M61199</guid>
      <dc:creator>pauldeen</dc:creator>
      <dc:date>2021-02-24T16:30:03Z</dc:date>
    </item>
  </channel>
</rss>

