cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar

Creating drop down menu for interactive user input

I have a question regarding JMP scripting. I am using JMP 11. I want to create an interactive script in JMP. The script will have the following elements -

1. The script will display a message asking the users to select a document. Users will select a document name.

2. Based on that selection, the remaining script will execute queries based on the user selected document and create relevant charts and tables.

I know how to achieve #2 in JMP. For #1, I know how to display a text box and have users enter the entire document name themselves but that would give opportunity for manual error and the remaining query won't work if wrong name is typed.

So I am thinking that a database query to the documents table will display all active documents as a drop-down list to the users and the users will only select one of the displayed documents. Is it possible to do in JMP scripting?

I looked into the scripting manual for making scripts interactive but the only options I saw involved having users enter the entire text. So wanted to check with you.

Thank you very much in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
DaveLee
Level IV

Re: Creating drop down menu for interactive user input

Just expanding a bit on john.ponte​'s post.  This is an example I received from WK and have modified often.

/* Open a sample data table */

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

/* Extract a list of unique ages */

Summarize( a = By( :age ) );

Insert Into( a, "<Select Age>", 1 );

/* Create a modal dialog */

New Window( "Example",

    <<Modal,

    H List Box(

        /* Upon selecting an age, populate the second ComboBox with corresponding names */

        Panel Box( "Select an Age:",

            cb1 = Combo Box(

                a,

                <<SetFunction(

                    Function( {this},

                        selection = this << Get Selected();

                        r = dt << Get Rows Where( :age == Num( selection ) );

                        ageNames = :name;

                        Insert Into( ageNames, "<Select Name>", 1 );

                        cb2 << Set Items( ageNames );

                    )

                )

            )

        ),

        /* Print the selected values from both ComboBoxes in the log */

        Panel Box( "Select a Name:",

            cb2 = Combo Box(

                {"<Select Name>"},

                <<SetFunction(

                    Function( {this},

                        that=this<< Get Selected();

                        Print( selection, that  )

                    )

                )

            )

        )

    )

);

sel=num(selection)

View solution in original post

2 REPLIES 2
JohnPonte
Staff (Retired)

Re: Creating drop down menu for interactive user input

To make a drop-down list in JSL all you need to do is create a List and a Combobox. Here is some sample JSL:

myList = {

   "<Select one>",

   "One",

   "Two",

   "Three",

   "Four",

   "Five"

};

doListChoice = expr(

    choice = myListbox << getSelected;

    show(choice);

);

myListbox = ComboBox(myList, doListChoice);

win = newWindow("Show List", myListbox);

Run this and you will see a drop-down list in a window. When you make your selection, it will display what you selected in the log.

The question now is how do you build your list? If your documents are files stored in a directory, I can show you some JSL to create a list from the directory. But it sounds like your documents are in a database? If that is the case, then I think you can query the database and get a list. Then use that list to create the combobox, as shown. I haven't scripted anything using a database though so my knowledge in that area is weak.

Does this answer your question? Or did you need help with querying the database?

DaveLee
Level IV

Re: Creating drop down menu for interactive user input

Just expanding a bit on john.ponte​'s post.  This is an example I received from WK and have modified often.

/* Open a sample data table */

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

/* Extract a list of unique ages */

Summarize( a = By( :age ) );

Insert Into( a, "<Select Age>", 1 );

/* Create a modal dialog */

New Window( "Example",

    <<Modal,

    H List Box(

        /* Upon selecting an age, populate the second ComboBox with corresponding names */

        Panel Box( "Select an Age:",

            cb1 = Combo Box(

                a,

                <<SetFunction(

                    Function( {this},

                        selection = this << Get Selected();

                        r = dt << Get Rows Where( :age == Num( selection ) );

                        ageNames = :name;

                        Insert Into( ageNames, "<Select Name>", 1 );

                        cb2 << Set Items( ageNames );

                    )

                )

            )

        ),

        /* Print the selected values from both ComboBoxes in the log */

        Panel Box( "Select a Name:",

            cb2 = Combo Box(

                {"<Select Name>"},

                <<SetFunction(

                    Function( {this},

                        that=this<< Get Selected();

                        Print( selection, that  )

                    )

                )

            )

        )

    )

);

sel=num(selection)