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.

202 Programming Methods Chapter 8<br />

Advanced Scoping and Namespaces<br />

Predefined Scopes<br />

JMP provides predefined that cannot be removed or replaced. Each of these scopes has specific roles,<br />

depending on its associated object.<br />

Table 8.5 Predefined Scopes<br />

Scope<br />

Global<br />

Here<br />

Builtin<br />

Local<br />

Local Here<br />

Window<br />

Platform<br />

Box<br />

Description<br />

Global names are shared throughout the JMP environment.<br />

Scope of the executing script.<br />

JMP built-in functions. For example, Builtin:Sqrt(). These names are shared<br />

throughout the JMP environment.<br />

If you over-ride a JSL function with a custom function, you can still access the<br />

built-in JSL function by using this scope.<br />

Nearest local scope. Can be nested within the user-defined functions, Local and<br />

Parameter.<br />

Provides a namespace block inside Names Default to Here(1). Local(<br />

{Default Local}, ) does not always work due to the lifetime of the local block,<br />

but Local Here() is persistent across the call.<br />

Scope of the containing user-defined window. (Rare.)<br />

Scope of the current platform. (Rare.)<br />

Scope of the containing context box. A context box is nested within a user-defined<br />

window. (Rare.)<br />

Example of Using the Window Scope<br />

This example uses the Window scope to pass information during execution. Explicitly scoping the variables<br />

x and y to this window ensures that JMP does not try to scope x and y in other contexts, such as a data<br />

table. The variables x and y are created and used solely inside the Window environment. The Window scope<br />

is similar to using Local(), but more useful because Local() is limited in the places that it can be used.<br />

New Window( "Example",<br />

window:gx = 20;<br />

window:gy = 50;<br />

Graph Box(<br />

Frame Size( 200, 200 ),<br />

Handle(<br />

window:gx,<br />

window:gy,<br />

Function( {x, y},<br />

window:gx = x;<br />

window:gy = y;

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

Saved successfully!

Ooh no, something went wrong!