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
Mad_dog_550
Level I

Using a variable for multiple commands

Hi All, 

I am looking for a way to use one variable in place of the individual commands in place of the multiple command lines. When I run this the Stacking window opens rather then executing the other commands included in the variable. I've also tried using combinations of EVAL() and PARSE() but with no better results.

 

I apologize if the terminology I've used isn't correct.

 

Thanks for any help!

 

 

test_variable = "columns( :Column1, :Column2 ),
	Source Label Column( \!"Label\!" ),
	Stacked Data Column( \!"Data\!" ),
	Move Columns( To First ),
	Output Table ( \!"Test Output Table\!" )";

current data table () << Stack (test_variable);
1 ACCEPTED SOLUTION

Accepted Solutions
hogi
Level XII

Re: Using a variable for multiple commands


@jthi wrote:

Usually you can build them in other ways (expressions) than using just strings (and I would say if you can, you should).

One approach is to use a placeholder ( _cols_ ) - and then replace (substitute) it with your pre-configured expression - like here:

 

Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

cols = Expr(Columns(:height, :weight));

mycommand = Expr(current data table () << Stack (_cols_, Source Label Column( "Label" ),
	Stacked Data Column( "Data" ),
	Move Columns( To First ),
	Output Table ( "Test Output Table" )));
	
Eval (Substitute ( Name Expr(mycommand),Expr(_cols_), Name Expr (cols) )) 

 

Some Expr() and Name Expr() "magic" is necessary to prevent JMP from executing expressions at the wrong time [Expr()] -  and to get access to the expression (Name Expr()) which is stored inside a variable (name) instead of the name itself.

 

At first sight, a user will decide that it's better to live without this overhead - or to use Eval(Parse(String)) as a fallback solution. But it's a good idea to invest some time here, e.g. with the help of this great lecture: 
Using JSL to Develop Efficient, Robust Applications (EU 2018 415) 

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Using a variable for multiple commands

What are you trying to do exactly? Use same selections in stack multiple times?

-Jarmo
Mad_dog_550
Level I

Re: Using a variable for multiple commands

I picked the Stack because it seemed like a simpler example of what I was trying to accomplish.  Ultimately, I wanted to use a variable to be used as a substitute for a block of command text in formatting a bunch of control charts. 

jthi
Super User

Re: Using a variable for multiple commands

Usually you can build them in other ways (expressions) than using just strings (and I would say if you can, you should).

-Jarmo
hogi
Level XII

Re: Using a variable for multiple commands


@jthi wrote:

Usually you can build them in other ways (expressions) than using just strings (and I would say if you can, you should).

One approach is to use a placeholder ( _cols_ ) - and then replace (substitute) it with your pre-configured expression - like here:

 

Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

cols = Expr(Columns(:height, :weight));

mycommand = Expr(current data table () << Stack (_cols_, Source Label Column( "Label" ),
	Stacked Data Column( "Data" ),
	Move Columns( To First ),
	Output Table ( "Test Output Table" )));
	
Eval (Substitute ( Name Expr(mycommand),Expr(_cols_), Name Expr (cols) )) 

 

Some Expr() and Name Expr() "magic" is necessary to prevent JMP from executing expressions at the wrong time [Expr()] -  and to get access to the expression (Name Expr()) which is stored inside a variable (name) instead of the name itself.

 

At first sight, a user will decide that it's better to live without this overhead - or to use Eval(Parse(String)) as a fallback solution. But it's a good idea to invest some time here, e.g. with the help of this great lecture: 
Using JSL to Develop Efficient, Robust Applications (EU 2018 415)