14.03.2014 Views

Scripting Guide - SAS

Scripting Guide - SAS

Scripting Guide - SAS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 8 Programming Methods 223<br />

Encrypt and Decrypt Scripts<br />

Encryption and Global Variables<br />

Encryption alone does not hide global variables and their values. A Show Globals() command displays<br />

them normally. If you want to hide global variables in an encrypted script, you can give them special names.<br />

Any global variable whose name begins with two underscore characters (__) is hidden, and Show<br />

Globals() displays neither its name nor its value. For example:<br />

myvar = 2;<br />

__myvar = 5;<br />

Show Symbols();<br />

//Globals<br />

myvar = 2;<br />

// 2 Globals (1 Hidden)<br />

This strategy works whether your script is encrypted or not.<br />

Encrypting Scripts in Data Tables<br />

You can also encrypt a script that is saved to a data table using the JSL Encrypted() or Include( Char<br />

to Blob() ) functions.<br />

• JSL Encrypted() is more straightforward, because it involves one function. You can include<br />

comments inside the encrypted script.<br />

• Include( Char to Blob() ) lets you include comments, but not inside the script.<br />

Follow these steps to encrypt a data table script:<br />

1. Place the script in a script window.<br />

You cannot directly encrypt a script that is already saved to a data table.<br />

2. In the script window, select Edit > Encrypt.<br />

3. Enter a decrypt password.<br />

4. (Optional) Enter a run password to require the user to enter a password before running the script.<br />

5. If you entered only a decrypt password, click Yes to confirm that you do not want to assign a run<br />

password.<br />

The encrypted script opens in a new script window.<br />

6. Copy the entire encrypted script.<br />

7. Create a new data table script or open an existing script.<br />

8. In the script portion of the window, type one of the following functions:<br />

JSL Encrypted( "" );<br />

Include( Char to Blob( "" ) );<br />

9. Paste the encrypted script inside the quotation marks in the function.<br />

10. Click OK.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!