cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Jemster
Level III

Modal Box If Statement Not Assigning Value to Variable

Using the code below I offer the user the choice of 4 products to analyse.

I use an if statement to open the correct file for the correct product.

I also assign a number for a variable I will need at a later date.

When I attempt to print this variable I get an error saying Name Unresolved at line 18.

It appears time_mult is somehow not being properly defined.

 

win = New Window( "Product Choice",
	<<Modal,
	<<On Validate(x = cb<<Get(),
		If(x == 1, y="File Path 1" ; time_mult=24,
		   x == 2, y="File Path 2" ; time_mult=168,
		   x == 3, y="File Path 3" ; time_mult=168,
		   x == 4, y="File Path 4" ; time_mult=168,
		);
	),
	cb = Combo Box(
		{"Product 1", "Product 2", "Product 3", "Product 4"},
	),
	Button Box("OK"),
	Button Box("Cancel"),
);
Print(x);
Print(y);
Print(time_mult);

 

The following test code works perfectly and seems to me to look almost identical. I was wondering if anyone can identify what's going wrong

win = New Window( "Combo Box",
	<<Modal,
	<<On Validate(x = cb<<Get();
		If(x == 1, y="/H:/Example Folder/File 1.xlsx" ; z=5,
		   x == 2, y="/H:/Example Folder/File 2.xlsx" ; z=63,
		   Stop()
		);
	),
	cb = Combo Box(
		{"One", "Two"},
	),
	Button Box("OK"),
	Button Box("Cancel"),
);

Print(x);
Print(y);
print(z);

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Jemster
Level III

Re: Modal Box If Statement Not Assigning Value to Variable

I needed a semi colon at the end of line 3

View solution in original post

txnelson
Super User

Re: Modal Box If Statement Not Assigning Value to Variable

The issue is that you have a comma after the statement instead of a semicolon

x = cb<<Get(),

The On Validate() function has only 1 element

On Validate( expr )

When there is a comma after the statement, JMP sees

On Validate( expr, expr );

and it executes only the first element

Jim

View solution in original post

2 REPLIES 2
Jemster
Level III

Re: Modal Box If Statement Not Assigning Value to Variable

I needed a semi colon at the end of line 3

txnelson
Super User

Re: Modal Box If Statement Not Assigning Value to Variable

The issue is that you have a comma after the statement instead of a semicolon

x = cb<<Get(),

The On Validate() function has only 1 element

On Validate( expr )

When there is a comma after the statement, JMP sees

On Validate( expr, expr );

and it executes only the first element

Jim