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.

212 Programming Methods Chapter 8<br />

Advanced Scoping and Namespaces<br />

Example of Local:a<br />

Sample Script<br />

Delete Symbols();<br />

Local( {d1l1 = 12},<br />

local:f1f1 = Function( {fa1,<br />

fa2},<br />

{fl1 = 99},<br />

local:fa12 = fa1 + fa2;<br />

Local( {d2l1 = 56},<br />

local:l2l2 = 78;<br />

Show( fa12 );<br />

Show( fl1 );<br />

Try( Show( d1l1 ), Write(<br />

"\!n\!n***Error=" || Char(<br />

exception_msg ) || "\!n" ) );<br />

Show Symbols();<br />

);<br />

local:fa12;<br />

);<br />

f1f1( 2, 3 );<br />

);<br />

Log Output<br />

fa12 = 5;<br />

fl1 = 99;<br />

***Error={"Name Unresolved:<br />

d1l1"(1, "d1l1", d1l1)}<br />

// Local<br />

d2l1 = 56;<br />

l2l2 = 78;<br />

// 2 Local<br />

// Local<br />

fa1 = 2;<br />

fa12 = 5;<br />

fa2 = 3;<br />

fl1 = 99;<br />

// 4 Local<br />

// Local<br />

d1l1 = 12;<br />

// 1 Local<br />

// Global<br />

exception_msg = {"Name<br />

Unresolved: d1l1"(1, "d1l1",<br />

d1l1)};<br />

// 1 Global<br />

5<br />

Resolving Named Variable References<br />

When variables are referenced within a JMP script, JMP resolves the storage location of the variable using a<br />

specific set of rules. If the variable is referenced by a qualified name, then the resolution is based on the<br />

specific qualification specification. If the variable is referenced by an unqualified name, the situation is a bit<br />

more complex. JMP looks through a hierarchy of scopes representing the point of execution with the<br />

executing script. This section describes the rules that are used to resolve named variable references.<br />

By default, variable name resolution in JMP 9 and later works the same way as in JMP 8 and earlier,<br />

allowing your current JSL scripts to be executed unchanged. For JMP 9 and later, the difference between

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

Saved successfully!

Ooh no, something went wrong!