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
HarryG
Level I

removing {} from << get selected variable

the output below puts { } on the date_selection variable. How do I remove the brackets.

output = {"date1"};

desired output = "date1";

date_list = Column( 2 ) << get values;
Show( date_list );
run_select = New Window( "checkboxes",
	<<modal(),
	V List Box(
		cb_list = Check Box( date_list ),
		Button Box( "OK", date_selection = cb_list << get selected )
	)
);
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: removing {} from << get selected variable

All you need to do, is to set the value of the returned variable to being the subscript as you generate the variable.

button box("OK",date_selection=(cb_list<<get selected)[1])

by specifying the date_selection this way, date_selection will be a just a plain numeric variable.

Jim

View solution in original post

12 REPLIES 12
julian
Community Manager Community Manager

Re: removing {} from << get selected variable

Hi @HarryG,

When you send the message "<< get selected" to the checkbox cb_list, JMP will return a list of all the selected elements, which as you noticed is not equivalent to a simple text string (which is what the { } indicate). If you wish to access the just the text "date1," and that's the first element in the list date_selection, you can subscript the list either with brackets or the subscript function:  date_selection[1]   or   subscript(date_selection,1).  Both of these operations will return "date1" if that's the first element in your list. 

I hope this helps!

@julian

HarryG
Level I

Re: removing {} from << get selected variable

Thanks @julian for the quick response! also thanks for letting me know my output is a List and not a simple string.  this case the output selection will always be only 1, so a list is not needed.

when I use either  date_selection[1]   or   subscript(date_selection,1) my output now looks like {{"date1"}}. Another set of brackets is added. I wanted to reduce the number of brackets, not add them. LOL! :)

txnelson
Super User

Re: removing {} from << get selected variable

All you need to do, is to set the value of the returned variable to being the subscript as you generate the variable.

button box("OK",date_selection=(cb_list<<get selected)[1])

by specifying the date_selection this way, date_selection will be a just a plain numeric variable.

Jim
HarryG
Level I

Re: removing {} from << get selected variable

Thanks @txnelson!!

that did the trick! the output is now a simple string as desired.

ankitgssingh
Level III

Re: removing {} from << get selected variable

Hello 

 

I have a follow up question on this. If I want all the items in the list instead of a single one and I dont want them in brackets similar to the above question. What can I do to get that? 

 

If I try this, I get the first item only without brackets. 

button box("OK",date_selection=(cb_list<<get selected)[1])

 

If I try this, I get all the items but with brackets. I want all the items in cb_list but without the brackets. 

button box("OK",date_selection=(cb_list<<get selected))

 

txnelson
Super User

Re: removing {} from << get selected variable

The  << get selected message returns a JMP list.  JMP Lists are noted by the curly brackets { "A", "B", "C" }.  Just like a JMP matrix is noted by square brackets  [ 4, 3, 5 ].

Why do you want the curly brackets removed?

Jim
ankitgssingh
Level III

Re: removing {} from << get selected variable

What if I want all the items in the list but without brackets. So something like this "Cats", "Dogs" instead of {"Cats", "Dogs"} ? 

 

As in my case the list if the list of columns selected in a data filter. I want to use that list of columns in a formula column to concat the values in those list of columns. 

 

 

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

myPlatform = New Window( "Filter Col Selector Example",
fontobj = lb = Filter Col Selector( width( 250 ) ),
button box("OK", date_selection=(lb<<get selected); myPlatform << close window;)
);



//creating the formulacol

dt << new column("FINALNEW", Formula(Concat( date_selection ) ) );
txnelson
Super User

Re: removing {} from << get selected variable

I think this is the best way to handle the issue

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );

date_selection = {"name", "sex"};
cString = concat items(date_selection, ","); Eval( Parse( "dt << new column(\!"FINALNEW\!", Formula(Concat(" || cString || " ) ) );" ) );
Jim
vince_faller
Super User (Alumni)

Re: removing {} from << get selected variable

I'll always argue against Eval(Parse())  

You can just do the concat items directly with << Set Each Value (so you don't need to have the variable set)

 

 

Names default to here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

myPlatform = New Window( "Filter Col Selector Example", << modal, 
	fontobj = lb = Filter Col Selector( width( 250 ) ),
	button box("OK", date_selection=(lb<<get selected))
);



//creating the formulacol

dt << new column("FINALNEW", character, <<SetEachValue(Concatitems( date_selection, "," ) ) );

I wonder what you're actually doing with that column if it's really a list of dates, it might be worth just putting the list into a column as an expression column type.  Depending on how you're using this column.  

 

// using an expression column
dt << new column("FINALNEW_expression", expression, <<SetEachValue(date_selection ) );

 

 

 

Vince Faller - Predictum