Subscribe Bookmark RSS Feed

Can jsl save .jsl

ram_asra_gmail_

Community Trekker

Joined:

Mar 21, 2013

I am wondering if jsl can save a script.jsl?

3 REPLIES
Craige_Hales

Staff

Joined:

Mar 21, 2013

I think you are asking how to use JSL to make another JSL script, something like this:

Save Text File( "$temp\deleteme.jsl", "print(42);" );

Include( "$temp\deleteme.jsl" );

42

Craige
ram_asra_gmail_

Community Trekker

Joined:

Mar 21, 2013

Thank you Craige.

i was looking to save an open .jsl file using another jsl

but i will give a try to your suggestion. Your idea seems better.

Thanks

Ram

Craige_Hales

Staff

Joined:

Mar 21, 2013

Welcome.  You could operate a text editor via the Menu() function, or you could do something like this (run one line at a time, watch the log window):

// make a file#1

x = Save Text File( "$temp\deleteme1.jsl", "print(42)" );

// open it; savetextfile returned the pathname to "x"

y = Open( x ); // opens an editor window

// grab the text from the editor and save it to file #2...

z = Save Text File( "$temp\deleteme2.jsl", (y[Script Box( 1 )]) << gettext );

// close the editor...

(y[Script Box( 1 )]) << closewindow;

// look in the log to verify...

Load Text File( z ); // echo the text

The menu function requires knowing what window has focus.  This code requires a variable ( y ) pointing to the editor.  The previous JSL-only (no editor) approach is probably easier if it works for you.

Craige