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

String Col Box: how to pass a list of strings to a String Col Box as N individual strings.

Hi, 

I'm having an issue with an outline string col box. Please see the attached image. StringColBoxIssue2.png

 

 

 

My issue is that instead of being able to individually provide each string as in the first example, I'm only able to provide a string list as the variable "ListOfStrings" in the image. 

Instead of having x y z in three different rows as in the first table, I have them in the same row which doesn't work with me. 

 

I would live any guidance in this matter. I need to be able to provide a list of strings and still have the same output format as the first table. 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: String Col Box: how to pass a list of strings to a String Col Box as N individual strings.

Use an Eval() function to have JMP evaluate the variable listofStrings and it will replace the variable, with the value of the variable.

Names Default To Here( 1 );

listofStrings = {"x", "y", "z"};

New Window( "Example2",
	Outline Box( "table2",
		Table Box(
			String Col Box( "names", Eval( listofStrings ) ),
			Number Col Box( "values", {11, 12, 13} ),
			Plot Col Box( "values", {11, 12, 13} )
		)
	)
);

txnelson_0-1707184637218.png

 

Jim

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: String Col Box: how to pass a list of strings to a String Col Box as N individual strings.

Use an Eval() function to have JMP evaluate the variable listofStrings and it will replace the variable, with the value of the variable.

Names Default To Here( 1 );

listofStrings = {"x", "y", "z"};

New Window( "Example2",
	Outline Box( "table2",
		Table Box(
			String Col Box( "names", Eval( listofStrings ) ),
			Number Col Box( "values", {11, 12, 13} ),
			Plot Col Box( "values", {11, 12, 13} )
		)
	)
);

txnelson_0-1707184637218.png

 

Jim
RA899
Level III

Re: String Col Box: how to pass a list of strings to a String Col Box as N individual strings.

Thank you @txnelson. It works now! 

 

Just for a reference:

I actually used Eval before but it was returning an error message. I realized it was because I used {} brackets and inserted the eval function inside it. I used this code:

String Col Box( "ONLY CHOOSE ONE BLOCK",  { Eval (buffer)	} );

  

jthi
Super User

Re: String Col Box: how to pass a list of strings to a String Col Box as N individual strings.

You are unnecessarily converting it to a string and that's why you are getting the list there.

Names Default To Here(1);

vals = {"x", "y", "z"};
vals_char = Char(vals);

Show(vals, vals_char, type(vals), type(vals_char));

The print for vals_char can look a bit weird on log as JMP escapes the quotes (you can use Write() to avoid that if you need to).

 

 

You can use what @txnelson suggested, but Eval shouldn't be necessary (in this case)

Names Default To Here(1);

vals = {"x", "y", "z"};

nw = New Window("Example",
	Outline Box("Table",
		Table Box(
			scb = String Col Box("names", vals),
			Number Col Box("values", {11, 22, 33}),
			Plot Col Box("values", {11, 22, 33})
		)
	)
);
-Jarmo
RA899
Level III

Re: String Col Box: how to pass a list of strings to a String Col Box as N individual strings.

Thank you @jthi ! The method above is a simplification of the code I have. The actual code is I have a list that I need to print out like the x y z above.  Its identical to the code below. I have tried to use eval and char functions. Eval returns an error, but char return a window like the one I provided initially where all the variables ( x,y.. ) are in one line. What I did is to convert the buffer list into a string list and then evaluate it like using (Eval) like the method @txnelson provided. 


buffer = {x, y, x, w};
  nw = New Window ( "take user input",
	<<Modal,
	Table Box(
		String Col Box( "insert value",  char(buffer)	    ),// 
nb = Number Col Edit Box( "", [0,0,0,0], targetint = nb << get as matrix; ) ), bb = Button Box( "OK", targetint = nb << get as matrix ), Button Box( "Cancel" ) );

 Anyway, it works now, but is there are a way to do so without using eval ? Just curious. Thanks.

jthi
Super User

Re: String Col Box: how to pass a list of strings to a String Col Box as N individual strings.

And if your x,y,x,w are numbers, you cannot use them in String Col Box as it is only for strings (convert them to characters first if that is the case or use Number Col Box). You will get error message like

Not a string in access or evaluation of 'String Col Box' , Bad Argument(1), String Col Box/*###*/("names", vals)

Using Transform Each (if you have jmp16+) is easy way to convert those

Names Default To Here(1);

a = 1;
b = 2;
c = 3;

mylist = {a, b, c};
valsnum = Eval List(mylist);

valstr = Transform Each({curval}, valsnum, Char(curval));

show(valsnum, valstr);

 

Also in general, if you have variables inside a list those might not get always evaluated. So you can evaluated them with Eval List()

Names Default To Here(1);

a = "X";
b = "Y";
c = "Z";

mylist = {a, b, c};
vals = Eval List(mylist);
show(mylist, vals);
-Jarmo