14.03.2014 Views

Scripting Guide - SAS

Scripting Guide - SAS

Scripting Guide - SAS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

80 JSL Building Blocks Chapter 5<br />

Global and Local Variables<br />

Preceding local variables with the Local() function is another option. Both a and b are local variables in<br />

the following expression:<br />

Local( {a = 1, b}, ... )<br />

Scoping operators also distinguish a global variable from a local variable. For more information, see “Name<br />

Resolution” on page 97.<br />

The following sections describe functions that help you manage variables.<br />

Show Symbols, Clear Symbols, and Delete Symbols<br />

The Show Symbols() function lists all variables and namespaces that are defined both globally and in the<br />

local script, along with their current values. Here is an example of Show Symbols() messages that are<br />

shown in the log:<br />

Show Symbols();<br />

// Here<br />

a = 5;<br />

b = 6;<br />

// 2 Here<br />

// Global<br />

c = 10;<br />

// 1 Global<br />

Tip: The JSL debugger also shows you the values of variables and namespaces. See “Debug Scripts” on<br />

page 56 in the “<strong>Scripting</strong> Tools” chapter for more information.<br />

The Clear Symbols() function erases the values set for variables that are defined both globally and in the<br />

local script. For example, after you clear and then show symbols, the variables are empty.<br />

Clear Symbols();<br />

Show Symbols();<br />

// Here<br />

a = Empty;<br />

b = Empty;<br />

// 2 Here<br />

// Global<br />

c = Empty;<br />

// 1 Global<br />

Note: The older Show Globals() and Clear Globals() functions are aliases of the newer Show<br />

Symbols() and Clear Symbols() functions.<br />

To remove all global variables and namespaces, use the function Delete Symbols(). After the last Show<br />

Symbols() in the following script is run, nothing shows up in the log. All variables have been completely<br />

removed from memory.<br />

Delete Symbols();<br />

Show Symbols();

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

Saved successfully!

Ooh no, something went wrong!