cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
adjo9835
Level II

JSL - Why do I get error first time running script, but second time onward works?

 

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.  Why is this?

DataCV=open("C:\Desktop\JMP\sample_CV_data.csv"); 
Summarize( DataCV, processArray = By( :process ) );
Summarize( DataCV, ctypeArray = By( :c_type ) );

For( n = 1, n <= Length( ctypeArray ), n++,		// Generates and saves all splines by :c_type and :process
	For( m = 1, m <= Length( processArray ), m++,
		Eval(
			Substitute(
					Expr(
						biv = Bivariate(
							Y( :c_mm_deembed_pf ),
							X( :v_dut_volt ),
							Where( :c_type == __ctype__ & :process == __process__ ),
							Fit Spline( 0.1, standardized, {save predicteds} )	
						)
					),
				Expr( __process__ ), processArray[m],
				Expr( __ctype__ ), ctypeArray[n],
			)
		)
	);
);

(Data Table( DataCV ) << 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 ) )
       )
)) << Make Into Data Table;

currentDataTable()<<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) & sn == (Row()=i;:serial_num),					
		i+=1	
	);				
	if (proc == (Row()=i;:process) & sn != (Row()=i;:serial_num),	
		CurrentDataTable()<<DeleteRows(i) 
	);
	if ((Row()=i;:process) == "",
		q = 1;
	);
);

currentDataTable() << Delete Rows(i);	// Delete empty last row
currentDataTable() << new column("Index", character);

cap = "new";
for (k = 1, k<=NRows(currentDataTable()), k++,	// Add VARs for ADS indexing
	if (cap != :c_type[k], 
		currentDataTable() << 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() << 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 () << Save As( "C:\JMP\GeneratedFiles\RoughDraft2Output.mdf", "text" );	// Save as .MDF

 

 

 

6 REPLIES 6
Craige_Hales
Super User

Re: JSL - Why do I get error first time running script, but second time onward works?

Try something like this for a start. Is the error in that Eval? Does the table have a column named "m"?

For( m = 1, m <= Length( processArray ), m++,
	show(m,processArray[m]); // <<<<<< 
	Eval( ...

You can further isolate what's happening with an intermediate variable to hold (and print the nameexpr) the result of substitute.

Craige
adjo9835
Level II

Re: JSL - Why do I get error first time running script, but second time onward works?

Adding:

show(m,processArray[m]);

to the script results in the log showing:

m = 1;
processArray[m] = "DVT0002B";

therefore, the error must be inside of the Eval()?

The data table has no columns named "m".

Craige_Hales
Super User

Re: JSL - Why do I get error first time running script, but second time onward works?

Pretty cool script!

 

Try this version

 

DataCV = Open( "$sample_data/big class.jmp" );
Summarize( DataCV, processArray = By( :age ) );
Summarize( DataCV, ctypeArray = By( :sex ) );

For( n = 1, n <= Length( ctypeArray ), n++,
    Show( n, ctypeArray[n] );
    For( m = 1, m <= Length( processArray ), m++,
        Show( m, processArray[m] );
        temp = Substitute(
                Expr(
                    biv = Bivariate(
                        Y( :height ),
                        X( :weight ),
                        Where( :sex == __ctype__ & :age == Num( __process__ ) ),
                        Fit Spline( 0.1, standardized, {save predicteds} )
                    )
                ),
            Expr( __process__ ), processArray[m],
            Expr( __ctype__ ), ctypeArray[n],

        );
        Show( Name Expr( temp ) );
        Eval( temp );
    );
);

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.

 

 

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.

 

@EvanMcCorkle 

 

Craige
adjo9835
Level II

Re: JSL - Why do I get error first time running script, but second time onward works?

Thanks! I feel pretty good about it considering this is my first time using JMP and that file conversion isnt a typical JMP application.

Im still getting the same error, only on the first time running the script, shown below.image.png

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.  Implying that it went through one full iteration of the for loop shown below:

For( n = 1, n <= Length( ctypeArray ), n++,

The 1 spline that was created and saved into a new column is shown below:image.png

I am going to try and update to JMP 14, to see if that solves the problem.  I have been using JMP 13.0.0

Jazib
Level II

Re: JSL - Why do I get error first time running script, but second time onward works?

@adjo9835 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

pauldeen
Level VI

Re: JSL - Why do I get error first time running script, but second time onward works?

Have you tried throwing in a 

Names default to here(1);

at the beginning of your script.

 

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.