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 5 JSL Building Blocks 97<br />

Name Resolution<br />

Host Information<br />

The Host Is() inquiry function identifies the current operating system. Then actions specific to that<br />

operating system can be performed.<br />

For example, if the operating system is Windows, the following script loads a Windows Dynamic Link<br />

Library (DLL):<br />

If(Host is(Windows),<br />

dll_obj = Load DLL("C:/Windows/System32/user32.dll")<br />

);<br />

You could also use Host Is() to specify text sizes in reports for different operating systems. If you<br />

commonly write your scripts on Windows and share them with Macintosh users, the results can look<br />

different from what you intended. For example, the following expression sets the text to a larger size on<br />

Macintosh and a smaller size on Windows:<br />

textsize = if(host is(Mac),12,10);<br />

Version Information<br />

The JMP Version() inquiry function returns the JMP version as a string. You might use this function to<br />

determine the JMP version and then run a script compatible with that version.<br />

JMP Version(); // returns "10.0.0" in JMP 10<br />

JMP Version(); // returns " 9.0.0" in JMP 9<br />

Notice that a leading blank is inserted before versions less than 10.0.0. This blank helps when comparing<br />

version numbers. Without the leading blank, 9.0.0 is interpreted as greater than 10.0.0.<br />

Name Resolution<br />

In JMP, you identify the following types of objects by a name:<br />

• Columns and table variables in a data table<br />

• Global variables, which hold values for the remainder of a JMP session<br />

• Scriptable object types<br />

• Arguments and local variables inside formulas<br />

Most of the time, you can just use an object’s name directly to refer to the object. Consider the following<br />

example:<br />

ratio = height / weight;<br />

Depending on the complexity of your script, it might be obvious that ratio is a variable and height and<br />

weight are data table column names. But what if the meanings are ambiguous? A script might use ratio as a<br />

global variable and as column names.<br />

JMP interprets object names using name resolution. The following rules are applied in order to unscoped<br />

names:

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

Saved successfully!

Ooh no, something went wrong!