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
ehchandlerjr
Level V

JMP crashing from some combination of nested If(for(if())) loops, "string" || i for column reference, eval() -> expr(), and concat() + char()

I feel like this is a simple question, but I can't for the life of me get this to work.

 

The context is I have an XML extractor that frustratingly has to deal with n-tuples of mostly (aside from one row) redundant entries a couple levels into the structure. I'm trying to find those "duplicate" entries, and check if they are indeed duplicates before I import them into my larger table. I've got the checking the number of repeats down, but I'm having a horrible time getting my nested for/if loop to work. In fact, the loop consistently crashes the whole software if I have an Eval( Eval Expr(....Expr())) nested in the wrong place. I'm not sure why this is, and I'm wondering if I am just misunderstanding how to use that construction.

 

I suppose it may also be an issue with using char() and concatenate90 nested inside one another, though again, I'm not sure why that would be. The current code I have below crashes the software.

colnames = dt << Get Column Names( String );
show(colnames);
reps = 0;
show(reps);
For( i = 1, i <= N Items( colnames), i++,
	reps = Sum( reps, Contains(colnames[i], "Data - Common Counting Time")); show(reps)
);

check = 0;
//Repeats that split columns
colnamecount = "Scan Append Number_4"; //Using a file that only has three of these columns, so show(colnamecount) = *_4 means its not going past that first if statment
If( reps> 1,
	For( i = 2, i = reps, i++,
		Eval(Eval Expr(colnamecount = Concat("Scan Append Number_", Char(Expr(i))))); //This is the issue
		If(dt:{"Scan Append Number_1"}[1] == Column( colnamecount )[1],
			check = check + 1,
			check = check + 12
		)
	)
);
show(check);

The code doesn't work regardless, but until I can get that If statment comparing the column with the concatenated name to the first of the n-tupled columns, it doesn't matter, and first I need to get the concatenation to work and not crash jsl.

 

Anyone have any thoughts? Am I just being dumb with syntax?

 

 

Edward Hamer Chandler, Jr.
2 ACCEPTED SOLUTIONS

Accepted Solutions
hogi
Level XII

Re: JMP crashing from some combination of nested If(for(if())) loops, "string" || i for column reference, eval() -> expr(), and concat() + char()

For the concatenation you don't need the Eval(Eval Epr(Expr())), you can reduce it to

for(i=2,i<10,i++,
colname=Concat("Scan Append Number_", Char(i));
Print(colname));

View solution in original post

ehchandlerjr
Level V

Re: JMP crashing from some combination of nested If(for(if())) loops, "string" || i for column reference, eval() -> expr(), and concat() + char()

@hogi Good point! So in my fatigue last night, I forgot to mention in my original question that I actually turned to the Eval(Eval Expr(Expr())) construct specifically because the simple Char(i) version didn't work, and was my first source of a crash in the software. 

 

However, I found the issue. I was treating the second condition of a for loop to be "until", whereas its a "while" condition. So rather than an inequality, I had an equality (i = reps), so my guess is that it was just iterating until ∞, because for some reason it stopped on one test, and i was 137, and reps should be at max 3. 

 

I've learned something today.

 

Thanks for your help!

Edward Hamer Chandler, Jr.

View solution in original post

2 REPLIES 2
hogi
Level XII

Re: JMP crashing from some combination of nested If(for(if())) loops, "string" || i for column reference, eval() -> expr(), and concat() + char()

For the concatenation you don't need the Eval(Eval Epr(Expr())), you can reduce it to

for(i=2,i<10,i++,
colname=Concat("Scan Append Number_", Char(i));
Print(colname));
ehchandlerjr
Level V

Re: JMP crashing from some combination of nested If(for(if())) loops, "string" || i for column reference, eval() -> expr(), and concat() + char()

@hogi Good point! So in my fatigue last night, I forgot to mention in my original question that I actually turned to the Eval(Eval Expr(Expr())) construct specifically because the simple Char(i) version didn't work, and was my first source of a crash in the software. 

 

However, I found the issue. I was treating the second condition of a for loop to be "until", whereas its a "while" condition. So rather than an inequality, I had an equality (i = reps), so my guess is that it was just iterating until ∞, because for some reason it stopped on one test, and i was 137, and reps should be at max 3. 

 

I've learned something today.

 

Thanks for your help!

Edward Hamer Chandler, Jr.