cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-473963%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EPregunta%20en%20ComboBox%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-473963%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPuedo%20crear%20opciones%20para%20Combo%20Box%20con%20sugerencias%20emergentes%20usando%20algo%20as%C3%AD%20(encontr%C3%A9%20esto%20experimentalmente)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Alist%20%3D%20%7B%22One%22%20(%22This%20is%20One%22)%2C%20%22Two%22%20(%22This%20is%20two%22)%7D%3B%0ANew%20Window(%20%22Example%22%2C%0A%20cb%20%3D%20Combo%20Box(%0A%20%20list%2C%20%0A%20%20selection%20%3D%20cb%20%26lt%3B%26lt%3B%20GetSelected()%3B%0A%20%20Print(%20selection%20)%3B%0A%20)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EPero%20luego%2C%20cuando%20miro%20la%20selecci%C3%B3n%2C%20solo%20tiene%20%22Uno%22%20o%20%22Dos%22%20como%20resultado%20de%20%26lt%3B%26lt%3B%20Ser%20seleccionado.%3C%2FP%3E%3CP%3EDos%20preguntas%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1.%20%C2%BFQu%C3%A9%20tipo%20de%20estructura%20de%20datos%20es%20la%20lista%20anterior%3F%20%C2%BFEs%20una%20lista%20de%20qu%C3%A9%3F%20list%5B1%5D%20me%20da%20exactamente%20%22Uno%22%20(%22Este%20es%20uno%22)%20-%20%C2%BFes%20una%20cadena%20o%20qu%C3%A9%20es%3F%3C%2FP%3E%3CP%3E2.%20%C2%BFC%C3%B3mo%20trabajo%20con%20esta%20lista%3F%20Digamos%20que%20si%20fuera%20una%20lista%20normal%20como%20%7B%22Uno%22%2C%20%22Dos%22%7D%2C%20pondr%C3%ADa%20en%20una%20parte%20del%20script%20algo%20como%20esto%3A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eif(%0Aselection%20%3D%3D%20list%5B1%5D%2C%20doThis%2C%0Aselection%3D%3Dlist%5B2%5D%2C%20doThat%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EPero%2C%20%C2%BFc%C3%B3mo%20lo%20hago%20cuando%20tengo%20sugerencias%20emergentes%20incluidas%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-473963%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3Esecuencias%20de%20comandos%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-473989%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Pregunta%20en%20ComboBox%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-473989%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EEn%20su%20ejemplo%2C%20List%20es%20una%20lista%20que%20tiene%202%20entradas.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%22Uno%22%20(%22Este%20es%20uno%22)%3C%2FLI%3E%0A%3CLI%3E%22Dos%22%20(%22Esto%20es%20dos%22)%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EEl%20cuadro%20combinado%20divide%20cada%20entrada%20de%20la%20lista%20en%20Item%20y%20tipstr.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eselection%20%3D%20cb%20%26lt%3B%26lt%3B%20GetSelected()%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Edevuelve%20solo%20el%20art%C3%ADculo%3C%2FP%3E%0A%3CP%3ESi%20desea%20que%20se%20devuelva%20el%20tipstr%2C%20debe%20usar%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Etipstr%20%3D%20(cb%20%26lt%3B%26lt%3B%20get%20items)%5Bcb%20%26lt%3B%26lt%3B%20Get%5D%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-474016%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Pregunta%20en%20ComboBox%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-474016%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EGracias%2C%20Jim.%3C%2FP%3E%3CP%3ETodav%C3%ADa%20no%20est%C3%A1%20muy%20claro%3A%20%C2%BFcada%20entrada%20es%20una%20cadena%3F%20%C2%BFD%C3%B3nde%20se%20escaparon%20las%20comillas%3F%3C%2FP%3E%3CP%3EY%20si%20quiero%20usar%20la%20misma%20lista%20en%20una%20declaraci%C3%B3n%20if%20en%20un%20script%20para%20el%20cuadro%20combinado%2C%20%C2%BFtendr%C3%ADa%20que%20extraer%20el%20elemento%20en%20s%C3%AD%3F%20Me%20gusta%3A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eif(%0Aselection%20%3D%3D%20Word(1%2C%20list%5B1%5D%2C%20%22%5C!%22()%22)%2C%20doThis%2C%0Aselection%3D%3DWord(1%2C%20list%5B2%5D%2C%20%22%5C!%22()%22)%2C%20doThat%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-474023%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Pregunta%20en%20ComboBox%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-474023%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPuede%20haber%20un%20miembro%20de%20la%20comunidad%20que%20tenga%20una%20mejor%20manera%20de%20lidiar%20con%20la%20estructura%20de%20la%20lista%20Combo%20Box%2C%20pero%20la%20%C3%BAnica%20forma%20en%20que%20descubr%C3%AD%20c%C3%B3mo%20manejarla%20es%20convirtiendo%20la%20lista%20completa%20en%20una%20cadena%20y%20luego%20analiz%C3%A1ndola%20con%20el%20Funci%C3%B3n%20de%20palabra%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Alist%20%3D%20%7B%22One%22%20(%22This%20is%20One%22)%2C%20%22Two%22%20(%22This%20is%20two%22)%7D%3B%0Atipstr1%20%3D%20word(4%2Cchar(list)%2C%22%5C!%22%22)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eque%20regresa%3C%2FP%3E%0A%3CPRE%3E%22This%20is%20One%22%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
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