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

Select where with hide and exclude does not work in a for loop

Hello community,

 

I want to be able to use the for loop to update row exclusions, but when I use it, all the rows get hidden/excluded. Would appreciate any help.

 

// This works
dt << select where( :Flag !="");
dt << hide and exclude;

// This does not work
For( i = 1, i <= N Items( hides ), i++,
	dt << select where( hides[i] !="");
	dt << hide and exclude;
);

// Neither does this
dt << select where( hides[1] !="");
dt << hide and exclude;

I know I am asking a lot of questions, since I do not have formal training on jsl, and I am still learning most of the stuff on the fly while completing a project. Would appreciate any good scripting guide manuals. I have the official one, but it still seems incomplete.

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Select where with hide and exclude does not work in a for loop

Is the "Official" scripting guide, the Scripting Guide available under the Help pull down menu?

The code for your script

For( i = 1, i <= N Items( hides ), i++,
	dt << select where( hides[i] !="");
	dt << hide and exclude;
);

Needs to be changed to

For( i = 1, i <= N Items( hides ), i++,
	dt << select where( As Column( dt, hides[i] ) != "" );
	dt << hide and exclude;
);
Jim

View solution in original post

6 REPLIES 6
jthi
Super User

Re: Select where with hide and exclude does not work in a for loop

What does hides contain?

-Jarmo
Kenobi
Level III

Re: Select where with hide and exclude does not work in a for loop

it contains a list of columns that the user selects in a column dialog, so something like 

{:Flag, :OZONE}
jthi
Super User

Re: Select where with hide and exclude does not work in a for loop

Are you trying to hide and exclude all rows which aren't missing in those columns?

-Jarmo
Kenobi
Level III

Re: Select where with hide and exclude does not work in a for loop

Yes indeed. When I run the first 2 lines of code, it works fine, but when I am running the same code, using list items, it hides and excludes the entire data table.

jthi
Super User

Re: Select where with hide and exclude does not work in a for loop

Try adding AsColumn() around your hides[i].

 

Not directly related to this, but if you have JMP16+ it is usually better to use For Each instead of For

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(4),
	Compress File When Saved(1),
	New Column("Column 1", Character, "Nominal", Set Values({"a", "", "a", ""})),
	New Column("Column 2", Character, "Nominal", Set Values({"", "b", "b", ""}))
);

cols = {:Column 1, :Column 2};

For Each({cur_col}, cols, // if you have JMP16+ usually better to use For Each than for
	dt << Select Where(cur_col != "") << Hide and Exclude(1) << Clear Select
);
-Jarmo
txnelson
Super User

Re: Select where with hide and exclude does not work in a for loop

Is the "Official" scripting guide, the Scripting Guide available under the Help pull down menu?

The code for your script

For( i = 1, i <= N Items( hides ), i++,
	dt << select where( hides[i] !="");
	dt << hide and exclude;
);

Needs to be changed to

For( i = 1, i <= N Items( hides ), i++,
	dt << select where( As Column( dt, hides[i] ) != "" );
	dt << hide and exclude;
);
Jim