cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
miguello
Level VII

Question on ComboBox

I can create options for Combo Box with pop up tips using something like that (found this experimentally):

 

Names Default To Here( 1 );
list = {"One" ("This is One"), "Two" ("This is two")};
New Window( "Example",
	cb = Combo Box(
		list, 
		selection = cb << GetSelected();
		Print( selection );
	)
);

But then when I look at the selection - it only has "One" or "Two" as a result of << Get Selected.

Two questions:

 

1. What kind of data structure is the list above? It's a list of what? list[1] gives me exactly "One"("This is one") - is it a string, or what is it?

2. How do I work with this list, let's say if it was a normal list like {"One", "Two"}, I would put in a script part something like this:

if(
selection == list[1], doThis,
selection==list[2], doThat
);

But how do I do it when I have pop up tips included?

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Question on ComboBox

There may be a Community member that has a better way of dealing with the Combo Box list structure, but the only way that I figured out how to deal with it is by making the whole list into a string, and then parsing it out with the Word Function

Names Default To Here( 1 );
list = {"One" ("This is One"), "Two" ("This is two")};
tipstr1 = word(4,char(list),"\!"");

which returns

"This is One"
Jim

View solution in original post

pmroz
Super User

Re: Question on ComboBox

The scripting index shows that structure for tip strings in the combo box.  I never realized you could include tooltips with a combobox - neat feature.

pmroz_0-1648558827313.png

You can create the "real" list from the list with tooltips.  Also I'd refrain from using "list" as a variable, as it is a function in JSL.

Names Default To Here( 1 );
list_tips = {"One" ("This is One"), "Two" ("This is two")};
New Window( "Example",
	cb = Combo Box(
		list_tips, 
		selection = cb << GetSelected();
		Print( selection );
	)
);

mylist = {};
for (i = 1, i <= nitems(list_tips), i++,
	pq = contains(list_tips[i], "(\!"");
	mylist[i] = substr(list_tips[i], 1, pq - 1);
);

if (
	selection == mylist[1], doThis,
	selection == mylist[2], doThat
);

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Question on ComboBox

In your example, List is a list that has 2 entries.

  1. "One" ("This is One")
  2. "Two" ("This is two")

The Combo box divides each list entry into Item and tipstr.

selection = cb << GetSelected();

returns only the item

If you want the tipstr returned, you need to use

tipstr = (cb << get items)[cb << Get];

 

 

Jim
miguello
Level VII

Re: Question on ComboBox

Thanks, Jim.

Still not very clear - each entry is a string? Where quotes escaped?

And if I want to use the same list in an if statement in a script for the combobox, I would have to extract the item itself? Like:

if(
selection == Word(1, list[1], "\!"()"), doThis,
selection==Word(1, list[2], "\!"()"), doThat
);
txnelson
Super User

Re: Question on ComboBox

There may be a Community member that has a better way of dealing with the Combo Box list structure, but the only way that I figured out how to deal with it is by making the whole list into a string, and then parsing it out with the Word Function

Names Default To Here( 1 );
list = {"One" ("This is One"), "Two" ("This is two")};
tipstr1 = word(4,char(list),"\!"");

which returns

"This is One"
Jim
pmroz
Super User

Re: Question on ComboBox

The scripting index shows that structure for tip strings in the combo box.  I never realized you could include tooltips with a combobox - neat feature.

pmroz_0-1648558827313.png

You can create the "real" list from the list with tooltips.  Also I'd refrain from using "list" as a variable, as it is a function in JSL.

Names Default To Here( 1 );
list_tips = {"One" ("This is One"), "Two" ("This is two")};
New Window( "Example",
	cb = Combo Box(
		list_tips, 
		selection = cb << GetSelected();
		Print( selection );
	)
);

mylist = {};
for (i = 1, i <= nitems(list_tips), i++,
	pq = contains(list_tips[i], "(\!"");
	mylist[i] = substr(list_tips[i], 1, pq - 1);
);

if (
	selection == mylist[1], doThis,
	selection == mylist[2], doThat
);

Recommended Articles