Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
Mar
Mar
Level I

For loop with graph builder crashing JMP

My corperation just made JMP available and I just started using it today. I am writing a script to loop through specific columns to create 6 charts. The names of the column are only different by numbers 1 through 6.

 

You can see below that I am trying to get the loop to change the variable i from 1 to 6 and then creating a graph with xy variables that will change with each iteration. When I run this script though it crashes JMP. I cannot even get the debugger to load without crashing. I have successfully run this script with the for loop and i modifications, so something is wrong with my code. Any thoughts how I can fix this code?

 

i=0;
For(i=1,i=6,i++,
	Graph Builder(
		Size( 1154, 941 ),
		Variables(
			X( :Column( "T7 Car " || i || " Temp" ) ),
			Y( :Column( "P7 Car " || i || " Press" ) ),
			Overlay( :Name( "2018-13-07 Event Marker" ) )
		),
		Elements( Points( X, Y, Legend( 7 ) ) ),
		Local Data Filter(
			Add Filter(
				columns( :Rate, :FC3 ),
				Where( :Speed >= 12 & :Speed <= 50 ),
				Where( :Fuel >= 5 & :Gas <= 100 )
			)
		)
	);
);
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: For loop with graph builder crashing JMP

1. Remove the ":" in front of the Column() function.  The :Name() function does have the ":" but Column() does not.

2. The concatenation of the variable "i" needs to be converted to a character before the concatenation.  So add the Char() function to the concatenation.......    Char(i)

3. You have a variable named Fuel and a variable named Gas in your filter "Where() clause......they need to be either both Fuel or both Gas

Jim

View solution in original post

3 REPLIES 3
Highlighted
txnelson
Super User

Re: For loop with graph builder crashing JMP

1. Remove the ":" in front of the Column() function.  The :Name() function does have the ":" but Column() does not.

2. The concatenation of the variable "i" needs to be converted to a character before the concatenation.  So add the Char() function to the concatenation.......    Char(i)

3. You have a variable named Fuel and a variable named Gas in your filter "Where() clause......they need to be either both Fuel or both Gas

Jim

View solution in original post

Highlighted
Mar
Mar
Level I

Re: For loop with graph builder crashing JMP

txnelson,

 

Thank you for the help! I followed your steps and it got the script to stop crashing so I could run the debugger. Once I was in the debugger I finding that i would iterate right to i=6 and then just loop for infinity. Not sure why this was occurring, so I made some changes to match the formatting of the For() documentation from JMP. I also deleted the i=0; at the begining of the code.

 

For( i = 1, i <= 6, i++

After making these changes the code worked! Thank you again for the help!

Highlighted
pmroz
Super User

Re: For loop with graph builder crashing JMP

The second argument of the FOR statement is a WHILEEXPR, which should evaluate to a boolean result.  You had it as i = 6, which returns the value 6 which is technically "true".  So the statement just kept on going.  You have it correct now as i <= 6.

 

This code will run indefinitely, until you hit the ESC key:

for (i = 1, i = 6, i++,
	show(i);
);

From the log:

i = 6;
i = 6;
i = 6;
i = 6;
i = 6;
i = 6;
i = 6;
i = 6;
i = 6;
i = 6;
i = 6;
i = 6;
cancelled in access or evaluation of 'For' , For/*###*/(i = 1, i = 6, i++, Show( i ))

 

Article Labels

    There are no labels assigned to this post.