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

Open script window with script by JSL

Dear all,

 

I want to create a script by JSL,

that opens a complex script in a script window. The content of that script should be saved in that script and not in an extra file.

 

I found a way via a temporary file, that is opened after saving the script as a text string.

 

Is there an easier way to perform that task?

I was not able to open a script window by "main menu ("Script")" and paste it into etc. 

Thanks and best regards,

 

Names Default To Here( 1 );
temp_jsl_name="$TEMP\temp.jsl";

Assign(
	script_txt,
	"\[Names Default To Here( 1 );
]\"
);
Save Text File( temp_jsl_name , script_txt);

open(temp_jsl_name);
Georg
5 REPLIES 5
jthi
Super User

Re: Open script window with script by JSL

Saving and opening text file seems to be quite a good solution (you could also delete the file after saving).

 

It is also possible to use Script Box, but it isn't exactly same as Script Window but could work depending on the use case.

Names Default To Here( 1 );
temp_jsl_name="$TEMP\temp.jsl";

Assign(
	script_txt,
	"\[Names Default To Here( 1 );
]\"
);

Script = Script Box(script_txt, "JSL", 300, 100);
New Window("This is a script box", Script);
-Jarmo
Georg
Level VII

Re: Open script window with script by JSL

Thanks @jthi ,

the script box () does not fit to my need, but is a nice idea I wasn't aware.

 

I want to make available several scripts in Add-Ins or in Custom Menus, w/o using before saved files.

Georg

Re: Open script window with script by JSL

I don't think this is actually any different that what jthi provided, but it LOOKS a little different, because when you open a new window with the << script message, the window is large and honors the preferences you've set (like numbering and embedded log).

 

By writing the script you want to use within an expr() wrapper, you keep the benefits of all of the color formatting, paren matching, etc. This makes it much easier to write (and if needed, maintain) the script. Then you can use the char(name expr()) combination to convert the script expression to a string, which can be placed into the scriptbox. All that remains is reformatting the script to make it look as you'd expect.

 

So again, this isn't really different in philosophy from what jthi proposed, but it might look more like what you were expecting, due to the size of the window? If not, then apologies; I believe I unfortunately may have misunderstood what you're after.

 

Cheers,

Brady

 

 

Names Default To Here(1);

myScript = expr(
	
	names default to here(1);
	
	print("hello, world.")

);

nsw = new window("My script", <<script);

nsw[scriptbox(1)] << set text ( char( nameexpr( myScript ) ) ) << Reformat;

 

 

jthi
Super User

Re: Open script window with script by JSL

I would guess that is exactly what was looked for! Scriptbox is missing at least script editor settings (row numbering and embedded log in my case) and some options from toolbars (current data table).

 

jthi_0-1614232567098.png

 

-Jarmo
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Open script window with script by JSL

This might be all you need:

 

ww = New Window( "Window Title", << Script, "Names Default To Here( 1 );\!N" );

In the JMP Documentation Library or the Scripting Guide check out the 'Scripting the Script Editor' section.