cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Have your say in shaping JMP's future by participating in the new JMP Wish List Prioritization Survey
Choose Language Hide Translation Bar
JMen
Level I

What is the return type from a Get Selected (with list box)

Hello, I need to know what is the return type from a list box.

 

From the scripting Index:

 

Names Default To Here( 1 );
New Window( "Example",
	fontobj = lb = List Box(
		{"First Item", "Second Item", "Third Item"},
		width( 200 ),
		max selected( 2 ),
		nlines( 6 )
	)
);
lb << Set Selected( 2 );
Print( lb << Get Selected );

Gets returned:

 

{"Second Item"}

What object type is this return? List, array? how do I access items by index? How am I supposed to handle the contents within? If more than two items are selected using Ctrl, are several items returned in this list or array?

 

For example let's say I need to concatenate an existing string with the selected value from this list box.

 

 

What is the difference between << Get Selected and << Get Selected Indices? In most of the code snippets I'm seeing it is common to use Get Selected Indices and I don't get why would you retrieve just the indices if your ultimate goal is to retrieve the contents.

 

In addition, when using the Application Builder, how can I see my debugging prints? Will they go into the general log window?

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions

Re: What is the return type from a Get Selected (with list box)

Yes, the result returned from sending this message is a list. Yes, you access them by subscripts. So, list[index] works. You can use more than one index at a time. Indices start at 1, not 0.

 

You can concatenate strings which are literal values or stored in variables with the Concat() function or the || operator.

 

The << Get Selected message returns the items. The << Get Selected Indices returns their index in the list box instead. I use indices all the time with the specialized Choose() function instead of the general purpose If() function. So it all depends on your need and style and approach.

 

Names Default to Here( 1 );

list1 = { "Monday", "Tuesday", "Wednesday" };
list2 = { "Thursday", "Friday", "Saturday", "Sunday" };

first = list1[1];
nextCouple = list1[2::3]; // or list1[{2,3}];
Show( first, nextCouple );

together = list1 || list2;
Show( together );

newStr = "Existing string " || list1[1];
Show( newStr );

View solution in original post

2 REPLIES 2

Re: What is the return type from a Get Selected (with list box)

Yes, the result returned from sending this message is a list. Yes, you access them by subscripts. So, list[index] works. You can use more than one index at a time. Indices start at 1, not 0.

 

You can concatenate strings which are literal values or stored in variables with the Concat() function or the || operator.

 

The << Get Selected message returns the items. The << Get Selected Indices returns their index in the list box instead. I use indices all the time with the specialized Choose() function instead of the general purpose If() function. So it all depends on your need and style and approach.

 

Names Default to Here( 1 );

list1 = { "Monday", "Tuesday", "Wednesday" };
list2 = { "Thursday", "Friday", "Saturday", "Sunday" };

first = list1[1];
nextCouple = list1[2::3]; // or list1[{2,3}];
Show( first, nextCouple );

together = list1 || list2;
Show( together );

newStr = "Existing string " || list1[1];
Show( newStr );
Georg
Level VII

Re: What is the return type from a Get Selected (with list box)

Hi @JMen , welcome to the community.

In Addition to Marc_Bailey's Answer, you can let JMP tell you what type you got by:

type(lb << Get Selected);

I find this quite useful, as it is alway crucial what type of object you are dealing with.

Georg