cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Owen_Kim
Level II

Need help to find out the difference of two variables listed here

Dear All,

 

Let me ask a question regarding Text Edit Box() function

 

Goal

Copy and Paste Excel values (Certain SerialNumber) into text edit box  and sort the Panel box (inserted SerialNumber)

 

Owen_Kim_0-1673677223345.png

 

I created some script referring to examples in JMP community as below.

The script is needs to be updated though.

Delete Symbols();

Names Default To Here( 1 );

//Define Seperate function

SeparateString = Function( {TheString},
	TheList = Words(TheString," ");
	
	Return( TheList );
);



dt = Current Data Table();



Summarize( sn = by( :SN ) );
serial_total = sn;

//dt2 = New table("tmp", New Column("serialnumber",character, set values(sn)));

New Window("Debug",
	H List Box(

		V List Box(TEXT BOX("Copy and Paste SerialNumber list", <<set font style("Bold")),
		H List Box(
			Icon Box( "SearchIndex" ),
			Spacer Box( size( 5, 10 ) ),
			item_search_teb = Text Edit Box( "",
				<<set width( 200 ), 
// The filter_items function does the work
				<<set nlines( 10 )
			),
			reset_button = Button Box( "",
				<<set icon( "DebuggerDeleteBreakpoint" ),
				<<set script(
// Clear the filter and call the callback function
					item_search_teb << set text( "" );
				),
				<<set tip( "Clear filter" )
			),

		)
		,
		
		Button box("Filtering",
			
			tmp =Eval(item_search_teb <<get text);
			str = "MD5 MD6 MD7 MD8 ";
			split_str = Words(str," ");
			split_tmp = Words(tmp," ");
			
			
			
			serial_list = SeparateString(tmp);
			total_flag =Associative Array( serial_total );
			list_flag = Associative Array( serial_list );
			total_flag << intersect (list_flag);
			
			serial_total = total_flag << get keys;
		)
		
		)
		
	
		
		
	, 
		
		Panel Box( "SerialNumber list : "  ,
			disp_box = List Box( sn, Max Selected( 1 ), width( 200 ), nlines( 10 ) ), 

		), 
		
	);
	)

 

By the way, when I input below values in text edit box, it seems the extracted string has delimiter " ", but it cannot be splitted as I thought.

 

 

MD5
MD6
MD7
MD8

 

I added simple script to check if it is splitted well, as you can see below figure, "str" can be splitted, however, "tmp" cannot.

 

When I put the values to excel and compare it with Exact function, both value is just same, but seems like JSL classified two variable as different one.

 

 

 

tmp =Eval(item_search_teb <<get text);
str = "MD5 MD6 MD7 MD8 ";
split_str = Words(str," ");
split_tmp = Words(tmp," ");

 

Owen_Kim_1-1673677441237.png

 

Could you find out what is the difference and let me know the solution?

 

Many thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Need help to find out the difference of two variables listed here

Try using "\!N" as separator for tmp instead of " ".

Most likely the separator is some sort of row change and not " " when you copy-paste values from Excel. I'm not sure where your variable image is from (JSL Debugger?) but maybe it cannot show row changes properly?

 

Edit: Also depending on your application, sometimes you might be better off replacing all white spaces (or just different kinds of row changes) with some character (I usually use ¤) using Regex and then using Words to split on that character. I usually do this, because the copy-pasted values might have all kinds of weird whitespace characters and just splitting on \!N won't be enough.

 

Names Default To Here(1);

str = "asd b 

\!na
\!rb";
Print(str);

new_separator = "¤";
l = Words(Regex(str, "\s", new_separator, GLOBALREPLACE), new_separator);
Show(l);

 

 

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Need help to find out the difference of two variables listed here

Try using "\!N" as separator for tmp instead of " ".

Most likely the separator is some sort of row change and not " " when you copy-paste values from Excel. I'm not sure where your variable image is from (JSL Debugger?) but maybe it cannot show row changes properly?

 

Edit: Also depending on your application, sometimes you might be better off replacing all white spaces (or just different kinds of row changes) with some character (I usually use ¤) using Regex and then using Words to split on that character. I usually do this, because the copy-pasted values might have all kinds of weird whitespace characters and just splitting on \!N won't be enough.

 

Names Default To Here(1);

str = "asd b 

\!na
\!rb";
Print(str);

new_separator = "¤";
l = Words(Regex(str, "\s", new_separator, GLOBALREPLACE), new_separator);
Show(l);

 

 

-Jarmo
Owen_Kim
Level II

Re: Need help to find out the difference of two variables listed here

Thanks for kind explanation and good way for the debugging!

It's first time I learned Regular Expression (Regex) in JSL.

 

Many thanks!

 

FYI, I captured debugger tool for the snapshot as you mentioned.