cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How to call scripts and functions from inside a folder?

I have several scripts and functions which are called by my main JSL script. They are all working and are in one single folder.

I want to keep all scripts and functions inside a folder to have a layer of protection from unwanted modification while only having the main script outside. The main script will call the functions and files from this say "myScripts" folder. How to implement this in JSL - could I please have an example?

When it's too good to be true, it's neither
1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to call scripts and functions from inside a folder?

@Neo do you expect the user you are sharing your scripts with will run them or are they just for reference? If they primarily run the script, have you considered compiling the scripts into an add-in? Add-in files are stored in an add-in folder that is consistent from user to user e.g. Windows: C:\Users\<username>\AppData\Roaming\SAS\JMP\Addins\*.* .JMP recognizes the add-in directory regardless of who the user is. Include() works in add-ins and you can add additional files your script uses e.g. pictures.  The scripts and additional files are available to the user if they want to repurpose or review the code. There are ways to encrypt if you don't want the user to have access to the code as @txnelson suggested. 

View solution in original post

6 REPLIES 6

Re: How to call scripts and functions from inside a folder?

Hi Neo,

 

Will the include function work for you? Try this

 

Include("$SAMPLE_SCRIPTS/estimatingPi.jsl");

There are additional arguments. >>Parse Only will parse but not run script, >>Names Default to Here executes the script in its own name space. 

Neo
Neo
Level VI

Re: How to call scripts and functions from inside a folder?

@Jason_Wiggins  Thanks. The issue I see here is when I share the parent folder (say zipped via email), depending on where the user places the unzipped parent folder (containing the main script and the other scripts inside myScripts folder), the path to parent folder changes which means I cannot hard code the path to myScripts folder in my main script. Am I missing something?

When it's too good to be true, it's neither

Re: How to call scripts and functions from inside a folder?

@Neo do you expect the user you are sharing your scripts with will run them or are they just for reference? If they primarily run the script, have you considered compiling the scripts into an add-in? Add-in files are stored in an add-in folder that is consistent from user to user e.g. Windows: C:\Users\<username>\AppData\Roaming\SAS\JMP\Addins\*.* .JMP recognizes the add-in directory regardless of who the user is. Include() works in add-ins and you can add additional files your script uses e.g. pictures.  The scripts and additional files are available to the user if they want to repurpose or review the code. There are ways to encrypt if you don't want the user to have access to the code as @txnelson suggested. 

txnelson
Super User

Re: How to call scripts and functions from inside a folder?

You may want to look into encrypting the JSL files you do not want to have modified.  If they are encrypted, then JMP will not even display them in the log, thus keeping them secure.

Jim
Neo
Neo
Level VI

Re: How to call scripts and functions from inside a folder?

@txnelson Encrypting option sounds good. Could I have (/please point to) an example with one main script and two other scripts which the main script calls (with the these other two scripts encrypted)?

When it's too good to be true, it's neither
txnelson
Super User

Re: How to call scripts and functions from inside a folder?

  1. Read the documentation on Encrypting Scripts in the Scripting Guide
  2. Here is an example.  Note, the top part of the script saves a couple of already encrypted scripts.  Only the bottom of the script is what you would use to access saved encrypted scripts.
names default to here(1);


// Create some saved encrypted scripts

// Below is an encrypted script that simply does a
// oneway()Oneway( Y( :height ), X( :sex ) )
encrypt =
"//-e12.1
0,
200,4182eJwNy9kBwiAMANB9XIFwlENKE0KhoMD+g+j7f6z01jbXDE3LJBaeCTjQ15Own9a6fQoXi7LcDp5qFrvE96Rneht6PKMy28XR
/336IaXjqrRfBlcsB4SazIgNtDSCujmYUsRq8Jozgmp7HOwaXej6mXfdiMLfaTM2yic22QMpD47KhMnfakSI75AsitcPuvg0Sg==
,0,";
// Save to a file
save text file("$TEMP/encript1.jsl",encrypt);

// Here is a second encrypted script that is simply
// Distribution( Continuous Distribution( Column( :height ) ) )
anotherEncrypt = 
"//-e12.1
0,
224,4214eJwFwQkCwxAQAMD/9Auom+gu60zE/x/SGb5FBzdI3uv2eXW1FZf8JPN43VlFM1r2w+WbNuXU7A9M/X31V4EM5X6nEQJh8xPK
s6yuLeuWmcVN5KeK79TxUImohaaoWzK8cxUaVD9qZymQZFmNY+sp4k7UVwDGCcxeWyuG7rhTdnmy4o+WieaFBBXxIuQGprua2/mF
gakEBpHZN/sI7PMHIYc+CQ==
,0,";

// Save to a file
save text file("$TEMP/encript2.jsl",anotherEncrypt);

// Wait 10 seconds
wait(10);

// Here is the script that runs the 2 saved encrypted scripts

dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
include("$TEMP/encript1.jsl");
include("$TEMP/encript2.jsl");
Jim