Subscribe Bookmark RSS Feed

How can I pass a listbox selection properly to select where?

uwe_hiss

Community Trekker

Joined:

Aug 12, 2015

Dear all,

I'm very new in JMP and JSL.

How can I pass a listbox selection properly to select where?

It looks, the brackets {} are the problem.

Preferences(Excel Has Labels(1), Excel Selection(1));

dt= Open( Pick File( " "));

New Window( " ",

<<Modal,

vlist box(

Text Box("Select ..."),

mon = listbox({"Jan 15", "Mar 15", "May 15"}),

Button Box( "OK", cho = mon<< get selected),

));

show (cho);

dt << Select Where( :Stage == cho);

dt << invert row selection;

dt << delete rows;

Is there a way to fill a Listbox with all values from a named column (Stage) without doubles?

Many thanks,

Uwe

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

The list brackets won't be a problem if you use Contains() instead of ==, which also would support selection of multiple items.

dt << Select Where(Contains(cho, :Stage));

For for character columns the below command should fill a list box with unique column values.

mon = List Box(:Stage << get values)

4 REPLIES
pmroz

Super User

Joined:

Jun 23, 2011

In your case "cho" is a list, since you could make multiple selections.  I've modified your code so that a) you can only choose one item, and b) it pulls the item from the list for proper use.

dt = Open( Pick File( " " ) );

New Window( " ", <<Modal,

     V List Box(

           Text Box( "Select ..." ),

           mon = List Box( {"Jan 15", "Mar 15", "May 15"}, max selected( 1 ) ),

           Button Box( "OK", cho_list = mon << get selected ),

     )

);

cho = cho_list[1];

Show( cho );

dt << Select Where( :Stage == cho );

dt << invert row selection;

dt << delete rows;

Solution

The list brackets won't be a problem if you use Contains() instead of ==, which also would support selection of multiple items.

dt << Select Where(Contains(cho, :Stage));

For for character columns the below command should fill a list box with unique column values.

mon = List Box(:Stage << get values)

uwe_hiss

Community Trekker

Joined:

Aug 12, 2015

Hi,

thanks for both solutions, it works fine.

At moment the if clauses makes headache.

My Idea:

If the selected item (in List Box) == "Baseline" do not invert the selected rows on table but delete.

Otherwise invert and delete.

//!

clear log();

clear globals();

dt= Open( Pick File(" "));

New Window( " ", <<Modal,

V List Box(

  Text Box("Select ..."),

  mon = List Box(:Stage << get values),

  Button Box( "OK", cho = mon << get selected),

  )

);

dt << Select Where(Contains(cho, :Stage));

if (

  cho == "Baseline", dt << delete rows,

);

dt << invert row selection;

dt << delete rows;

Control Chart Builder(

  Show Control Panel( 0 ),

  Variables( Y( :Assay ) ),

  Chart(

  Position( 1 ),

  Warnings( Test 1( 1 ), Test 2( 1 ), Test 3( 1 ), Test 5( 1 ), Test 6( 1 ) )

  ),

  Chart( Position( 2 ) ),

  SendToReport(

  Dispatch( {}, "Control Chart Builder" , FrameBox, {Marker Size( 2 )} ),

  Dispatch( {}, "Control Chart Builder" , FrameBox( 2 ), {Marker Size( 2 )} )

  )

);

Whats wrong?

Regards,

Uwe

ms

Super User

Joined:

Jun 23, 2011

Looks like the end parenthesis is misplaced. Move it to after the "else" commands

If(cho == "Baseline",

    dt << delete rows,

    dt << invert row selection;

    dt << delete rows

);