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.

Chapter 8 Programming Methods 205<br />

Advanced Scoping and Namespaces<br />

New Namespace<br />

nsref = New Namespace( , );<br />

Creates a new namespace called nsname (a string expression) and returns a reference to the namespace. All<br />

arguments are optional.<br />

Nsname is the name of the namespace in the internal global list of namespace names. Nsname can be used as<br />

the prefix in a scoped variable. The function returns a reference to the namespace, and can also be used as<br />

the prefix in a scoped variable reference. If nsname is absent, the namespace is anonymous and is given a<br />

unique name created by JMP. Show Namespace() shows all namespaces and their names, whether assigned<br />

or anonymous.<br />

Important: If you already have a namespace named nsname, it is replaced. This behavior means that while<br />

you are developing your script, you can make your changes and re-run the script without having to clear or<br />

delete your namespace. To avoid unintentional replacement, you can either use anonymous namespaces, or<br />

test to see whether a particular namespace already exists:<br />

If( !Namespace Exists( "nsname" ), New Namespace( "nsname" ) );<br />

A list of named expressions is optional. The names are JMP variables that exist only within the namespace.<br />

Note: The named expressions must be a comma-separated list. Separating the expressions with semi-colons<br />

causes the list to be ignored.<br />

These namespaces must be uniquely named to prevent collisions in situations where multiple user-defined<br />

namespaces are being used. Using anonymous namespace names prevents collisions.<br />

Namespace<br />

nsref = Namespace( "nsname" | nsref);<br />

Returns a namespace reference. The argument might be any of the following:<br />

• a quoted string that contains a namespace<br />

• a reference to a namespace<br />

• a reference to an object that owns a namespace (such as a data table, a window, or a platform)<br />

If nsname is a data table, then the namespace for the data table columns is returned.<br />

Note: Namespace() returns a reference to a namespace that already exists. It does not create a new<br />

namespace.<br />

Is Namespace<br />

b = Is Namespace( nsref );<br />

Returns 1 (true) if nsref is a namespace or 0 (false) otherwise.

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

Saved successfully!

Ooh no, something went wrong!