cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
LBrian
Level III

How to use contains() correctly?

Hi, All

 

I wanna use contains(),

Names Default To Here( 1 );
dt = Open( "$Sample_Data/Blood pressure.jmp" );

colNamesList = dt << get column names( continuous );

Input = New Window( "example", << modal(),
	new1 = hlistbox(
	Text Box( "Test name :" ),
	Para_Num_teb = Text Edit Box( "", <<set width( 200 ) )
	),
		text box("Click OK"),
		Button Box( "OK", 
		Para_Num = Para_Num_teb << get text();
		),
);

if (!contains(colNamesList, Para_Num),
	Throw("Fail ")
);

however,

Fail message occurs everytime on this script which i made.

 

Could you give me any advice?

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to use contains() correctly?

The issue you are having is that you are retrieving a character string variable from your Button Box, but your list of column names are expressions

para_num = "zippy";

colnameslist = {BP 8M, BP 12M, BP 6M, BP 8W, BP 12W, BP 6W, BP 8F, BP 12F, BP 6F};

 

If you just specify to have the colNamesList returned as strings, your code will work

colNamesList = dt << get column names( continuous, string );

 

 

Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: How to use contains() correctly?

The issue you are having is that you are retrieving a character string variable from your Button Box, but your list of column names are expressions

para_num = "zippy";

colnameslist = {BP 8M, BP 12M, BP 6M, BP 8W, BP 12W, BP 6W, BP 8F, BP 12F, BP 6F};

 

If you just specify to have the colNamesList returned as strings, your code will work

colNamesList = dt << get column names( continuous, string );

 

 

Jim
LBrian
Level III

Re: How to use contains() correctly?

Thank you very much Doctor!!!