cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
UserID16644
Level V

IF Statement according to user input

Hi,

I am trying to create a basic script with an IF statement, I'm not that familiar if a CASE statement exist in JMP but what I'm try to do is similar to a case statement.

 

1. Ask the user to input a number ranging from 1-20 only

2. Create an if statement and execute the command with accordance to the user input

 For example: User input : 2

                        *Executes script inside bracket 2

 

Can you advise a basic tutorial set that might help with this?

1 ACCEPTED SOLUTION

Accepted Solutions
ThuongLe
Level IV

Re: IF Statement according to user input

You can try something like this

userinput = New Window( "Collect user input",	<<Modal, <<Return Result,
	V List Box(
		H List Box(
			Text Box("Input a number from 1 to 20: "),
			number = Text Edit box("")
		),
		Spacer Box(Size(10, 10)),
		H List Box( Spacer Box( 10, 80 ), Button Box( "OK" ), Button Box( "Cancel" ) ), 
	)		
);

If( userinput["Button"] == -1,
	db << close
);

number_input = userinput["number"];
if(num(number_input) < 1 | num(number_input) > 20,
	New Window("Error!!", Text Box("  Please input a number from 1 to 20 ONLY!  ")),
	if(num(number_input) == 1,
		//DO SOMETHING...
	num(number_input) == 2,
		//DO SOMETHING...
	);
);
Thuong Le

View solution in original post

2 REPLIES 2
ThuongLe
Level IV

Re: IF Statement according to user input

You can try something like this

userinput = New Window( "Collect user input",	<<Modal, <<Return Result,
	V List Box(
		H List Box(
			Text Box("Input a number from 1 to 20: "),
			number = Text Edit box("")
		),
		Spacer Box(Size(10, 10)),
		H List Box( Spacer Box( 10, 80 ), Button Box( "OK" ), Button Box( "Cancel" ) ), 
	)		
);

If( userinput["Button"] == -1,
	db << close
);

number_input = userinput["number"];
if(num(number_input) < 1 | num(number_input) > 20,
	New Window("Error!!", Text Box("  Please input a number from 1 to 20 ONLY!  ")),
	if(num(number_input) == 1,
		//DO SOMETHING...
	num(number_input) == 2,
		//DO SOMETHING...
	);
);
Thuong Le
pmroz
Super User

Re: IF Statement according to user input

You can be a more direct with your user interface.  Try this code:


nw = new window("Test",
	panel box("Click the icon to run the program: ",
		lineup box(ncol(2),
			text box("1. Tree Map"),
			button box("", << set icon("TreeMap"),
				<< set function(include("treemap.jsl"))),

			text box("2. Neural Net"),
			button box("", << set icon("NeuralNet"), 
				<< set function(include("NeuralNet.jsl"))),

			text box("3. Model Comparison"),
			button box("", << set icon("ModelComparison"), 
				<< set function(include("ModelComparison.jsl"))),

			text box("4. SAS Pyramid"),
			button box("", << set icon("SASPyramid"), 
				<< set function(include("SASPyramid.jsl"))),
		),
	),
);

You would substitute the appropriate code where I have <include("xxx.jsl")>.  To get the various icons use Justin Chilton's Built in JMP Icons addin.