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.

344 Display Trees Chapter 11<br />

How to Access Built-in Windows<br />

To let the user select a file, use the Pick File command.<br />

path = Pick File(<br />

, ,<br />

, , ),<br />

<br />

The prompt message is used as the window title. The "initial directory" defines which folder initially<br />

appears. If a directory is defined as an empty string, the default directory is used.<br />

You can also define the filter used for the Open window, forcing it to show only certain file types. This list<br />

must use the following syntax:<br />

{"Label1|suffix1;suffix2;suffix3", "Label2|suffix4;suffix5"}<br />

Each quoted string adds an entry to the File name list in the Open window. Label defines the text that is<br />

displayed for each menu option. The following list of suffixes defines the file types that are displayed if its<br />

corresponding label is selected. Note the use of * to list all files in the window.<br />

Pick File(<br />

"Select JMP File",<br />

"$SAMPLE_DATA",<br />

{"JMP Files|jmp;jsl;jrn",<br />

"All Files|*"},<br />

1, 0, "Earthquakes.jmp")<br />

Tip: All arguments are optional, however, they are also positional. This means that you can leave out<br />

arguments only at the end of the script. Use empty strings for the arguments that you want to omit from the<br />

beginning of the script.<br />

To obtain a list of filenames in a specific directory, use the Files In Directory command.<br />

names = Files In Directory(path, );<br />

On Macintosh, only the filenames are returned. On Windows, both filenames and subdirectory names are<br />

returned as shown in the following example:<br />

names = Files In Directory("$SAMPLE_DATA");<br />

{ "2D Gaussian Process Example.jmp", "Abrasion.jmp", ... "Design<br />

Experiment", "Detergent.jmp", ... }<br />

Notice that the files within the Design Experiment subdirectory are not included. And only files in the<br />

root $SAMPLE_DATA directory are listed. To return a list of all file names, add the optional recursive<br />

argument to Files In Directory:<br />

names = Files In Directory("$SAMPLE_DATA", recursive);<br />

{ "2D Gaussian Process Example.jmp", "Abrasion.jmp", ... "Design Experiment/<br />

2x3x4 Factorial.jmp", "Design Experiment/Borehole Factors.jmp", ... }<br />

To get the full pathnames, recurse the directories and concatenate the file paths and file names. The<br />

following example loops through each file in the $SAMPLE_DATA directory and subdirectories. The file path<br />

is concatenated to each file name.

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

Saved successfully!

Ooh no, something went wrong!