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
EFarrell
Level II

How do I display a text box asking for input from the user?

Hi,

 

I am trying to create a basic script which analyses my data.

 

When I press the thumbnail linked to the script, I want it to

1. Ask the user to input the ranges

2. Create a data table which shows the max and min

3. Generates a graph with the min, max and the target in it.

 

So far all I can do is get the script for the data table or the graph and incorporate it into shortcuts in JMP separately. I can't figure out how to get it to generate a generate a query box for the user and I can't incorporate the graph and the data table together. Can you advise a basic tutorial set that might help with this?

 

 

Kind regards,

 

Elaina

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: How do I display a text box asking for input from the user.

You can make either a modal or non-modal dialog in JMP with your custom prompt.

Modal dialogs won't let you do anything else until you complete them. http://www.jmp.com/support/help/Modal_Windows.shtml

Non-modal dialogs let you work in other windows and come back to the modeless window later: http://www.jmp.com/support/help/Constructing_Display_Trees.shtml#259363

A non-modal prototype of what you describe might look like this:

v1 = 30; // two numbers with default
v2 = 40; // values; these will go in a data table
w = New Window( "prototype", // 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( "value 1: " ), Number Edit Box( v1 ) ), // data entry
            Spacer Box( size( 1, 10 ) ), // a little vertical space
            H List Box( Text Box( "value 2: " ), Number Edit Box( v2 ) ), // more data entry
            Spacer Box( size( 1, 30 ) ), // a little vertical space
            H Center Box( // center the button
                Button Box( "make report", // this script runs when the button is pressed...
                    // make a new table with the values...
                    dt = New Table( "Untitled", New Column( "a", Set Values( {v1, v2} ) ) );
                    // launch a platform to analyze the data...
                    dt << Distribution( Continuous Distribution( Column( :a ), Quantiles( 0 ), Summary Statistics( 0 ), Vertical( 0 ), Outlier Box Plot( 0 ) ) );
                    // optionally, close the dialog. Or, you might want to run it again...
                    w << closeWindow; // just the dialog, not the report
                )
            )
        )
    )
);

Prototype dialogPrototype dialog

Craige

View solution in original post

9 REPLIES 9
Craige_Hales
Super User

Re: How do I display a text box asking for input from the user.

You can make either a modal or non-modal dialog in JMP with your custom prompt.

Modal dialogs won't let you do anything else until you complete them. http://www.jmp.com/support/help/Modal_Windows.shtml

Non-modal dialogs let you work in other windows and come back to the modeless window later: http://www.jmp.com/support/help/Constructing_Display_Trees.shtml#259363

A non-modal prototype of what you describe might look like this:

v1 = 30; // two numbers with default
v2 = 40; // values; these will go in a data table
w = New Window( "prototype", // 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( "value 1: " ), Number Edit Box( v1 ) ), // data entry
            Spacer Box( size( 1, 10 ) ), // a little vertical space
            H List Box( Text Box( "value 2: " ), Number Edit Box( v2 ) ), // more data entry
            Spacer Box( size( 1, 30 ) ), // a little vertical space
            H Center Box( // center the button
                Button Box( "make report", // this script runs when the button is pressed...
                    // make a new table with the values...
                    dt = New Table( "Untitled", New Column( "a", Set Values( {v1, v2} ) ) );
                    // launch a platform to analyze the data...
                    dt << Distribution( Continuous Distribution( Column( :a ), Quantiles( 0 ), Summary Statistics( 0 ), Vertical( 0 ), Outlier Box Plot( 0 ) ) );
                    // optionally, close the dialog. Or, you might want to run it again...
                    w << closeWindow; // just the dialog, not the report
                )
            )
        )
    )
);

Prototype dialogPrototype dialog

Craige
ian_jmp
Level X

Re: How do I display a text box asking for input from the user.

There seems to be another instance of this thread here. Please also see the reply I posted there.

Craige_Hales
Super User

Re: How do I display a text box asking for input from the user.

Hm. I wonder if I tested that JSL. The NumberEditBox does not update the v1/v2 variable when the field is changed, so the report is always the same. This is what it should be:

 

v1 = 30; // two numbers with default
v2 = 40; // values; these will go in a data table
w = New Window( "prototype", // 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( "value 1: " ), b1=Number Edit Box( v1 ) ), // data entry
            Spacer Box( size( 1, 10 ) ), // a little vertical space
            H List Box( Text Box( "value 2: " ), b2=Number Edit Box( v2 ) ), // more data entry
            Spacer Box( size( 1, 30 ) ), // a little vertical space
            H Center Box( // center the button
                Button Box( "make report", // this script runs when the button is pressed...
                    // make a new table with the values...
                    dt = New Table( "Untitled", New Column( "a", Set Values( {b1<<get, b2<<get} ) ) );
                    // launch a platform to analyze the data...
                    dt << Distribution( Continuous Distribution( Column( :a ), Quantiles( 0 ), Summary Statistics( 0 ), Vertical( 0 ), Outlier Box Plot( 0 ) ) );
                    // optionally, close the dialog. Or, you might want to run it again...
                    w << closeWindow; // just the dialog, not the report
                )
            )
        )
    )
);

With the extra b1 and b2 variables to remember the boxes, and the <<get message to those boxes, the report will show them.

The report isn't created until after the button is pressed. Artistic license.The report isn't created until after the button is pressed. Artistic license.

 

Craige

Re: How do I display a text box asking for input from the user.

Hi Craige,

 

I hope replying to an old thread is ok. I want to create some variables to be used as strings later in a script (user directories for file import which change depending on user) - I am trying to adapt your script to achieve this.

The idea is that the variables are first created with default values. Then the input box comes up, the user changes the values, the script continues and uses the now updated variables in an import.

 

//Import multiple files
Multiple File Import(
	<<Set Folder(
		"C:\Users\",userFirstName,userLastName,"File\Path\Example..."
),

So below will come first in the script:

 

 

 

// Defining firstname and lastname string

userFirstName = "XXXX";
userLastName = "YYYY";

//changing username variables based on user input

w = New Window( "prototype", // 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( "First Name: " ), b1=Text Edit Box( userFirstName ) ), // data entry
            Spacer Box( size( 1, 10 ) ), // a little vertical space
            H List Box( Text Box( "Last Name: " ), b2=Text Edit Box( userLastName ) ), // more data entry
            Spacer Box( size( 1, 30 ) ), // a little vertical space
            H Center Box( // center the button
                Button Box( "Update Strings", // this script runs when the button is pressed...
                    // make a new table with the values...
                    dt = New Table( "StringCheck", New Column( "Name", Character, Set Values( {b1<< get text(), b2 << get text()} ) ) );
                                        // optionally, close the dialog. Or, you might want to run it again...
                    w << closeWindow; // just the dialog, not the report
                )
            )
        )
    )
);

I successfully get the data input window, and a table called StringCheck with a character column "Name" - however the two values are "Send":

 

PerenniallyLate_0-1700067493237.png

I have tried a few different things to get it to work but for the life of me can't work out where "Send" is coming from.

 

Any help appreciated, thanks,

 

Late

jthi
Super User

Re: How do I display a text box asking for input from the user.

You are getting Send there because it is what is being "evaluated" to the table (<< means Send()) Most likely it will be enough to just wrap your list with Eval List() to evaluate the values there

 

Names Default To Here(1);

// Defining firstname and lastname string

userFirstName = "XXXX";
userLastName = "YYYY";

//changing username variables based on user input

w = New Window("prototype", // 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("First Name: "), b1 = Text Edit Box(userFirstName)), // data entry
			Spacer Box(size(1, 10)), // a little vertical space
			H List Box(Text Box("Last Name: "), b2 = Text Edit Box(userLastName)), // more data entry
			Spacer Box(size(1, 30)), // a little vertical space
			H Center Box( // center the button
				Button Box("Update Strings", // this script runs when the button is pressed...
					// make a new table with the values...
					dt = New Table("StringCheck",
						New Column("Name",
							Character,
							Set Values(Eval List({b1 << get text(), b2 << get text()}))
						)
					);
                                        // optionally, close the dialog. Or, you might want to run it again...
					w << closeWindow; // just the dialog, not the report
				)
			)
		)
	)
);

 

-Jarmo

Re: How do I display a text box asking for input from the user.

Hi Jarmo,

 

Thank you! This worked a treat! However, I have now run into two further issues. If I may describe them:

 

 

// Defining firstname and lastname string

userFirstName = "XXXX";
userLastName = "YYYY";

//changing username variables based on user input

w = New Window( "prototype", <<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( "First Name: " ), b1=Text Edit Box( userFirstName ) ), // data entry
            Spacer Box( size( 1, 10 ) ), // a little vertical space
            H List Box( Text Box( "Last Name: " ), b2=Text Edit Box( userLastName ) ), // more data entry
            Spacer Box( size( 1, 30 ) ), // a little vertical space
            H Center Box( // center the button
                Button Box( "Update Strings", // this script runs when the button is pressed...
                    // make a new table with the values...
                    dt = New Table( "StringCheck",
                    New Column( "Name", 
                    Character, 
                    Set Values(Eval List({b1 << get text(), b2 << get text()}))
                    )
                    );
                                                            // optionally, close the dialog. Or, you might want to run it again...
                    w << closeWindow; // just the dialog, not the report
                )
            )
        )
    )
);

// Defining filepath string

filePathString = Concat Items( {"C:\Users\", userFirstName, userLastName, "\File\Path\Example\etc\"}, "" );

//Import multiple files
Multiple File Import(
	<<Set Folder(
		filePathString
	),
	<<Set Show Hidden( 0 ),

First of all, pressing update strings does spit out the correct table, but it also throws an error:

 

PerenniallyLate_0-1700158388837.png

Secondly, the script "works", i.e., carries out the multiple file import, if I use the variables userFirstName & userLastName, but does not work if I use b1, b2 in the concatanate string. My guess as to why is that the part I am using to define the b1, b2 variables (using the Text Edit Box) is local. Do the b1,b2 variables not continue on to exist in the remaining script? If that is the case, how do I make them exist as global variables.

 

How do I get rid of the error? It seems to be caused by me adding a << modal clause to the window. But I need to do this in order to pause the script and allow the operator to check that their name input was correct.

 

Ideally the workflow I am trying to build is:

 

user runs the script

The script throws up a pop-up box, asking the user to define their first name and last name

The script allows the user to check that their entry is correct (showing the filePathString would be better than the current output)

The script, after the user clicks ok, continues, and uses the new variables in several different filePathStrings.

 

There are many other ways I could incorporate a data entry text box into this script for my purpose, so any help would be greatly appreciated.

 

Thanks,

Late

jthi
Super User

Re: How do I display a text box asking for input from the user.

You are getting this error, because you are using modal window and you are closing it "too early". Modal windows are special type of windows which basically require you to use specific button titles Scripting Guide > Display Trees > Modal Windows in JSL > Construct a Modal Window 

Note: Modal windows require at least one button for dismissing the window. You can use OK, Yes, No, or Cancel to label modal window buttons. If you do not include at least one of these buttons in a modal window, JMP adds an OK button.

 

Remove the w << closeWindow; from your Update String buttons. If you wish to close the window when that button is pressed (you will have unnecessary OK button), add OK button and then send click message to it. I think you can even hide the OK button if you want to

Names Default To Here(1);

// Defining firstname and lastname string

userFirstName = "XXXX";
userLastName = "YYYY";

//changing username variables based on user input

w = New Window("prototype",
	<<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("First Name: "), b1 = Text Edit Box(userFirstName)), // data entry
			Spacer Box(size(1, 10)), // a little vertical space
			H List Box(Text Box("Last Name: "), b2 = Text Edit Box(userLastName)), // more data entry
			Spacer Box(size(1, 30)), // a little vertical space
			H Center Box( // center the button
				Button Box("Update Strings", // this script runs when the button is pressed...
					// make a new table with the values...
					dt = New Table("StringCheck",
						New Column("Name",
							Character,
							Set Values(Eval List({b1 << get text(), b2 << get text()}))
						)
					);
					ok_btn << Click(1);
				)
			),
			ok_btn = Button Box("OK", << Visibility("Collapse"))
		)
	)
);

// Defining filepath string

filePathString = Concat Items(
	{"C:\Users\", userFirstName, userLastName, "\File\Path\Example\etc\"},
	""
);

 

-Jarmo

Re: How do I display a text box asking for input from the user.

Hi Jarmo,

 

Thanks again! One more question: Why does my script work when I use userFirstName and userLastName but does not work when I use b1,b2 in the Defining filepath string text:

 

// Defining firstname and lastname string

userFirstName = "XXXX";
userLastName = "YYYY";

//changing username variables based on user input

w = New Window( "Defining User Name", <<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( "Who are you?" ) ), // a second title, centered
            Spacer Box( size( 1, 30 ) ), // a little vertical space
            H List Box( Text Box( "First Name: " ), b1=Text Edit Box( userFirstName ) ), // data entry
            Spacer Box( size( 1, 10 ) ), // a little vertical space
            H List Box( Text Box( "Last Name: " ), b2=Text Edit Box( userLastName ) ), // more data entry
            Spacer Box( size( 1, 30 ) ), // a little vertical space
            H Center Box( // center the button
                Button Box( "Update Strings", // this script runs when the button is pressed...
                    // make a new table with the values...
                    dt = New Table( "StringCheck",
                    New Column( "Name", 
                    Character, 
                    Set Values(Eval List({b1 << get text(), b2 << get text()}))
                    )
                    );
                    ok_btn << Click(1)
                    )
                    ),
                    ok_btn = Button Box("OK", << Visibility("Collapse"))
                )
    )
);

// Defining filepath string

filePathString = Concat Items( {"C:\Users\", b1, b2, "\File\Path\Example\"}, "" );

//Import multiple files
Multiple File Import(
	<<Set Folder(
		filePathString
	),

Best,

 

Late

jthi
Super User

Re: How do I display a text box asking for input from the user.

b1 and b2 do not store the values, they are just references to your display boxes. And when you close your modal window, you will lose accese to those. You could store the values on button press

Names Default To Here(1);
// Defining firstname and lastname string

userFirstName = "XXXX";
userLastName = "YYYY";

//changing username variables based on user input

w = New Window("Defining User Name",
	<<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("Who are you?")), // a second title, centered
			Spacer Box(size(1, 30)), // a little vertical space
			H List Box(Text Box("First Name: "), b1 = Text Edit Box(userFirstName)), // data entry
			Spacer Box(size(1, 10)), // a little vertical space
			H List Box(Text Box("Last Name: "), b2 = Text Edit Box(userLastName)), // more data entry
			Spacer Box(size(1, 30)), // a little vertical space
			H Center Box( // center the button
				Button Box("Update Strings", // this script runs when the button is pressed...
					// make a new table with the values...
					b1_val = b1 << get text;
					b2_val = b2 << get text;
					dt = New Table("StringCheck",
						New Column("Name",
							Character,
							Set Values(Eval List({b1 << get text(), b2 << get text()}))
						)
					);
					ok_btn << Click(1);
				)
			),
			ok_btn = Button Box("OK", <<Visibility("Collapse"))
		)
	)
);

show(b1, b2);
Try(b1 << get text, show(exception_msg)); // this will error as the display box is gone
show(b1_val);

b1_val and b2_val. And if you use something like that, you should also use those when adding values to your table

-Jarmo