BookmarkSubscribe
Choose Language Hide Translation Bar
HarryG
Community Trekker

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(),
vlistbox(cb_list=check box(date_list),
button box("OK",date_selection=cb_list<<get selected)
)
);

 

 

0 Kudos
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
0 Kudos
4 REPLIES 4
julian
Staff

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

0 Kudos
HarryG
Community Trekker

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! :)

0 Kudos
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
0 Kudos
HarryG
Community Trekker

Re: removing {} from << get selected variable

Thanks @txnelson!!

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

0 Kudos