cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
Choose Language Hide Translation Bar
View Original Published Thread

Question on ComboBox

miguello
Level VI

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 VI


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
);