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

How to activate a button box with "desired script" from the text box.

As shown below, when the user inputs the desired script into the text box(ex. Distribution( Continuous Distribution( Column( :X) ) );)

and then executes the button box, how can the corresponding script be executed as analysis? Thanks for letting us know!

 

 

I want the script to be executed as analysis when the user inputs the desired script into the text box and then executes the button box as shown below.


How can I execute the text entered in the text box immediately with a button click?

CT_MG_0-1634630731843.png

 

Though I stored the desired script as a variable using get text() and write(), it is not executed as an analysis.
I would really appreciate it if you could tell me how to solve it.

MGO
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to activate a button box with "desired script" from the text box.

Use the Eval(Parse()) combination of functions to execute a text string of JSL

txnelson_0-1634639254977.png

txnelson_1-1634639283641.png

Names Default To Here( 1 );
New Window( "Enter Script",
	V List Box(
		tb = Text Edit Box( "", <<set width( 400 ), <<set script( theScript = tb << get text ) ),
		OKButton = Button Box( "OK", Eval( Parse( theScript ) ) )
	)
);

 

 

Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: How to activate a button box with "desired script" from the text box.

Use the Eval(Parse()) combination of functions to execute a text string of JSL

txnelson_0-1634639254977.png

txnelson_1-1634639283641.png

Names Default To Here( 1 );
New Window( "Enter Script",
	V List Box(
		tb = Text Edit Box( "", <<set width( 400 ), <<set script( theScript = tb << get text ) ),
		OKButton = Button Box( "OK", Eval( Parse( theScript ) ) )
	)
);

 

 

Jim
jemg
Level III

Re: How to activate a button box with "desired script" from the text box.

It works! 

Thanks all for your kindly help

MGO
ian_jmp
Level X

Re: How to activate a button box with "desired script" from the text box.

You need to look at the 'Parse()' function:

Names Default To Here( 1 );
txt = "x+y";
scr = Parse(txt);

x = 2; y = 3;
Print(scr);
Print(Eval(scr));

It feels like typing in a script this way would be quite error prone.