BookmarkSubscribeSubscribe to RSS Feed

how do you create a new script file from jsl

BrianK

Community Trekker

Joined:

Jan 19, 2017

 
3 ACCEPTED SOLUTIONS

Accepted Solutions
melaniedrake

Staff

Joined:

May 30, 2014

Solution

You can use Save Text File and use a .jsl extension.

Example:

script = "// here's some JSL\!rShow(\!"Hello, World!\!");";
Save Text File( "$desktop\MyScript.jsl", script );

 

Justin_Chilton

Joined:

Aug 27, 2015

Solution

You can also use the JSL Quote function to make creating a string of JSL code a little easier.

 

script = JSL Quote( // here's some JSL
Show("Hello, World!"); );
Save Text File( "$desktop\MyScript.jsl", script );
Justin
Craige_Hales

Staff

Joined:

Mar 21, 2013

Solution

You could also use the square-bracket quote mechanism, and then open the result in a script editor window. Note the backslash and the open or close square bracket are not part of the saved text, and the embedded quotes need no escaping.

filename = Save Text File(
	"$temp/DeleteMe.JSL", 
// this is the opening square-bracket quote
"\[ 
// comment 1
write("these quotes need no special treatment
and the newline works too
"); // comment 2
//comment 3
]\" // this is the closing square-bracket quote
);

editor = Open( filename, "script" ); // "script" might be needed if the extension is missing

scriptEditor.PNGScript Editor Window with contents of file

Craige
5 REPLIES
melaniedrake

Staff

Joined:

May 30, 2014

Solution

You can use Save Text File and use a .jsl extension.

Example:

script = "// here's some JSL\!rShow(\!"Hello, World!\!");";
Save Text File( "$desktop\MyScript.jsl", script );

 

Justin_Chilton

Joined:

Aug 27, 2015

Solution

You can also use the JSL Quote function to make creating a string of JSL code a little easier.

 

script = JSL Quote( // here's some JSL
Show("Hello, World!"); );
Save Text File( "$desktop\MyScript.jsl", script );
Justin
Craige_Hales

Staff

Joined:

Mar 21, 2013

Solution

You could also use the square-bracket quote mechanism, and then open the result in a script editor window. Note the backslash and the open or close square bracket are not part of the saved text, and the embedded quotes need no escaping.

filename = Save Text File(
	"$temp/DeleteMe.JSL", 
// this is the opening square-bracket quote
"\[ 
// comment 1
write("these quotes need no special treatment
and the newline works too
"); // comment 2
//comment 3
]\" // this is the closing square-bracket quote
);

editor = Open( filename, "script" ); // "script" might be needed if the extension is missing

scriptEditor.PNGScript Editor Window with contents of file

Craige
vince_faller

Super User

Joined:

Mar 17, 2015

How are you making it so the block string isn't all one color? Mine just looks like this:

 

Capture.PNG

 

Or is that just an artifact of the forum?

 

 

melaniedrake

Staff

Joined:

May 30, 2014

That's an artifact of the forum. It tries to use syntax coloring, but it doesn't parse JSL perfectly. So what is one string, and hence one color, in JMP confuses the parser here.