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
Starwatcher
Level III

JSL : Define variables based on user entry through a pop up window

Hello,

I would like to create a pop up window that allows the user to define variables without accessing the code. I managed to get the pop up to get the user entries based on previous posts, but wasn't able to pass it to the variables.

Could you please help me with this?

Thank you in advance

// Indicate here the name of the input HTML table
input_table = "http://xxx.html";

// Indicate here the name you want for your JMP data table
JMP_table_name = "JMP data table";


w = New Window( "User inputs", // opens a window with a title and this content...
    Border Box( top( 20 ), bottom( 20 ), Left( 20 ), Right( 20 ), // window dressing 
        V List Box( // V and H lists nest to organize the display boxes
            H Center Box( Text Box( "Report Generator" ) ), // a second title, centered
            Spacer Box( size( 1, 30 ) ), // a little vertical space
            H List Box( Text Box( "input_table: " ), input_table=Text Edit Box("http://xxx.html") ), // data entry
            Spacer Box( size( 1, 30 ) ), // a little vertical space
            H List Box( Text Box( "JMP_table_name: " ), JMP_table_name=Text Edit Box("JMP data table") ), // more data entry
            Spacer Box( size( 1, 30 ) ), // a little vertical space
            H Center Box( // center the button
                Button Box( "Submit", // this script runs when the button is pressed...
                    input_table = result["input_table"];
					JMP_table_name = result["JMP_table_name"];
                    w << closeWindow; // close the dialog
                )
            )
        )
    )
);
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: JSL : Define variables based on user entry through a pop up window

There are a couple of issues with your script.  The first one, ir that you are changing the data type of the Input_table and the JMP_table_name variables.  You start out with then defined as character strings, but then redefine them as Display fields.

Secondly, just because JMP is opening a window, does not stop the JSL processing, and wait for the user input.  JMP will just continue to process, unless the window is defined as a Modal window  See my modification of your script below.  I strongly suggest that you take the time to take the time to read the Scripting Guide.

// Indicate here the name of the input HTML table
input_table = "http://xxx.html";

// Indicate here the name you want for your JMP data table
JMP_table_name = "JMP data table";


w = New Window( "User inputs", <<modal, // opens a window with a title and this content...
	Border Box( top( 20 ), bottom( 20 ), Left( 20 ), Right( 20 ), // window dressing 
		V List Box( // V and H lists nest to organize the display boxes
			H Center Box( Text Box( "Report Generator" ) ), // a second title, centered
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H List Box( Text Box( "input_table: " ), input_table_teb = Text Edit Box( input_table ) ), // data entry
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H List Box( Text Box( "JMP_table_name: " ), JMP_table_name_teb = Text Edit Box( JMP_table_name ) ), // more data entry
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H Center Box( // center the button
				button = Button Box( "OK", // this script runs when the button is pressed...
					input_table = input_table_teb << get text;
					JMP_table_name = JMP_table_name_teb << get text;
					w << closeWindow; // close the dialog
				)
			)
		)
	)
);
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: JSL : Define variables based on user entry through a pop up window

There are a couple of issues with your script.  The first one, ir that you are changing the data type of the Input_table and the JMP_table_name variables.  You start out with then defined as character strings, but then redefine them as Display fields.

Secondly, just because JMP is opening a window, does not stop the JSL processing, and wait for the user input.  JMP will just continue to process, unless the window is defined as a Modal window  See my modification of your script below.  I strongly suggest that you take the time to take the time to read the Scripting Guide.

// Indicate here the name of the input HTML table
input_table = "http://xxx.html";

// Indicate here the name you want for your JMP data table
JMP_table_name = "JMP data table";


w = New Window( "User inputs", <<modal, // opens a window with a title and this content...
	Border Box( top( 20 ), bottom( 20 ), Left( 20 ), Right( 20 ), // window dressing 
		V List Box( // V and H lists nest to organize the display boxes
			H Center Box( Text Box( "Report Generator" ) ), // a second title, centered
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H List Box( Text Box( "input_table: " ), input_table_teb = Text Edit Box( input_table ) ), // data entry
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H List Box( Text Box( "JMP_table_name: " ), JMP_table_name_teb = Text Edit Box( JMP_table_name ) ), // more data entry
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H Center Box( // center the button
				button = Button Box( "OK", // this script runs when the button is pressed...
					input_table = input_table_teb << get text;
					JMP_table_name = JMP_table_name_teb << get text;
					w << closeWindow; // close the dialog
				)
			)
		)
	)
);
Jim
Starwatcher
Level III

Re: JSL : Define variables based on user entry through a pop up window

Hello,

I jumped into an additional issue.

I managed to get the modal window opening and passed the new variables definitions within the script for the input_table and  the JMP_table name.

Going on the variable I see that it was correctly updated.

Then, the rest of my script is supposed to perform actions, such as opening the table specified by the user (outside of the button), but it does not run.

I tried putting the whole script into the modal window, I tried also adding a wait() but this does not help.

If I run the script without the modal window it works fine, so the issue definitely comes from there.

Any idea how to solve this?

Here is the code.

// Initialize variables with default values

// Number of input data tables  (default = 1)
nb_join_tables = 2;

//links to the input HTML tables
input_table_01 = "http://xxx.html";
input_table_02 = "http://xxx.html";


//Create a pop up window to request user inputs for the variables

w = New Window( "User inputs", <<modal, // opens a window with a title and this content...
	Border Box( top( 20 ), bottom( 20 ), Left( 20 ), Right( 20 ), // window dressing 
		V List Box( // V and H lists nest to organize the display boxes
			H Center Box( Text Box( "From html to JMP data table" ) ), // a second title, centered
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H List Box( Text Box( "Number of tables you want to merge: " ), JMP_table_nb = Text Edit Box( nb_join_tables) ), 
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H List Box( Text Box( "Insert here the .html link to the tables you want to import : " )),
			Spacer Box( size( 1, 10) ), // a little vertical space
			H List Box( Text Box( "input table 01: " ), input_table_teb01 = Text Edit Box( input_table_01) ), 
			H List Box( Text Box( "input table 02: " ), input_table_teb02 = Text Edit Box( input_table_02) ), 
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H Center Box( // center the button
				button = Button Box( "OK", // this script runs when the button is pressed...
					w << closeWindow; // close the dialog
					nb_join_tables = JMP_table_nb << Get Text;
					input_table_01 = input_table_teb01 << Get Text;
					input_table_02 = input_table_teb02 << Get Text;			
				)
			)
		)
	)
);


// Name of the individual JMP data tables
JMP_table_01_name = "input01";
JMP_table_02_name = "input02";


// Create lists according to the number of tables to merge

tables_list = Eval List( {input_table_01,input_table_02} );
names_list= Eval List({JMP_table_01_name,JMP_table_01_name});
dt1={};
dt2={};
dt_list = Eval List({dt1,dt2});


For( i = 1, i <= nb_join_tables, i++,
		show(i, tables_list); // check the log window for the output
		//Open html data table from specific location
		dt_list[i]=Open(
			tables_list[i],
			HTML Table( 4, Column Names( 0 ), Data Starts( 1 ) )
		);
// Set JMP data table name to the desired one
		dt_list[i] << Set Name( names_list[i] );
);

 

Starwatcher
Level III

Re: JSL : Define variables based on user entry through a pop up window

I found the solution. I used a "Text Edit Box" and a "Get Text" for a numeric value. I modified to "Number Edit Box" and To "Get" and it works. :

// Initialize variables with default values

// Number of input data tables  (default = 1)
nb_join_tables = 2;

//links to the input HTML tables
input_table_01 = "http://xxx.html";
input_table_02 = "http://xxx.html";


//Create a pop up window to request user inputs for the variables

w = New Window( "User inputs", <<modal, // opens a window with a title and this content...
	Border Box( top( 20 ), bottom( 20 ), Left( 20 ), Right( 20 ), // window dressing 
		V List Box( // V and H lists nest to organize the display boxes
			H Center Box( Text Box( "From html to JMP data table" ) ), // a second title, centered
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H List Box( Text Box( "Number of tables you want to merge: " ), JMP_table_nb = Number Edit Box( nb_join_tables) ), 
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H List Box( Text Box( "Insert here the .html link to the tables you want to import : " )),
			Spacer Box( size( 1, 10) ), // a little vertical space
			H List Box( Text Box( "input table 01: " ), input_table_teb01 = Text Edit Box( input_table_01) ), 
			H List Box( Text Box( "input table 02: " ), input_table_teb02 = Text Edit Box( input_table_02) ), 
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H Center Box( // center the button
				button = Button Box( "OK", // this script runs when the button is pressed...
					w << closeWindow; // close the dialog
					nb_join_tables = JMP_table_nb << Get ;
					input_table_01 = input_table_teb01 << Get Text;
					input_table_02 = input_table_teb02 << Get Text;			
				)
			)
		)
	)
);



// Name of the individual JMP data tables
JMP_table_01_name = "input01";
JMP_table_02_name = "input02";


// Create lists according to the number of tables to merge

tables_list = Eval List( {input_table_01,input_table_02} );
names_list= Eval List({JMP_table_01_name,JMP_table_01_name});
dt1={};
dt2={};
dt_list = Eval List({dt1,dt2});


For( i = 1, i <= nb_join_tables, i++,
		show(i, tables_list); // check the log window for the output
		//Open html data table from specific location
		dt_list[i]=Open(
			tables_list[i],
			HTML Table( 4, Column Names( 0 ), Data Starts( 1 ) )
		);
// Set JMP data table name to the desired one
		dt_list[i] << Set Name( names_list[i] );
);
Starwatcher
Level III

Re: JSL : Define variables based on user entry through a pop up window

Thank you so much!

Thanks also for explaining the mistakes I made; this will definitely help me through it in the future.

Have a good day!