Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
LBrian
Level II

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
Highlighted
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
Highlighted
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

Highlighted
LBrian
Level II

Re: How to use contains() correctly?

Thank you very much Doctor!!!
Article Labels