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
Monomorphist
Level III

Script command to check whether a selection criteria returns >0 selected rows

I'm looking for a scripting command that checks whether a selection contains >0 selected rows. The issue: subsetting a table of selected rows when none are selected, stops the script and returns an error message. I circumvent this problem by creating a column that sets selected rows to 1, then take col sum and run the if command (if col sum > 0, subset, don't subset). But that's clunky and for loops with sometimes >1mio repeats, adds significant time to the process. Are there more elegant solutions? For example, the number of selected rows appears in the data table (row module, usually in left bottom corner), meaning JMP does count the selected rows internally, somewhere. Is there a way to retrieve this number in the script?

1 ACCEPTED SOLUTION

Accepted Solutions
Monomorphist
Level III

Re: Script command to check whether a selection criteria returns >0 selected rows

Not quite, because "get selected rows" returns a list, not the number of selected rows. Still good idea! I get selected rows as list and can query the number of items in the list. Thanks!

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Script command to check whether a selection criteria returns >0 selected rows

You can use << Get Selected Rows and check the amount if items in the amtrix

If(dt << get selected rows < 1,
	stop();
);
-Jarmo
Monomorphist
Level III

Re: Script command to check whether a selection criteria returns >0 selected rows

Not quite, because "get selected rows" returns a list, not the number of selected rows. Still good idea! I get selected rows as list and can query the number of items in the list. Thanks!

jthi
Super User

Re: Script command to check whether a selection criteria returns >0 selected rows

Yeah I did paste incorrect code, it was supposed to be wrapped in N Items() (N Rows and N Cols should also work, but N Items is the most clear)

Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");
dt << select rows(1::10);

If(N Items(dt << get selected rows) < 1,
	Show("stop1");
	stop();
);


show("continue1");


dt << clear select;
If(N Items(dt << get selected rows) < 1,
	Show("stop2");
	stop();
);

show("continue2");

 

-Jarmo
hogi
Level XII

Re: Script command to check whether a selection criteria returns >0 selected rows

doesn't look like a "solution"

hogi_0-1731360209704.png