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 8 Programming Methods 231<br />

Functions that Communicate with Users<br />

The sequence \!N inserts the line breaking characters that are appropriate for the host environment. For an<br />

explanation of the three line breaking escape sequences, see “Double Quotes,” p. 72 in the “JSL Building<br />

Blocks” chapter.<br />

Send information to the User<br />

Beep<br />

Speak<br />

Caption<br />

Beep causes the user’s computer to make an alert sound.<br />

Speak reads text aloud. On Macintosh, Speak has one Boolean option, Wait, to specify whether JMP<br />

should wait for speaking to finish before proceeding with the next step. The default is not to wait, and you<br />

need to issue Wait(1) each time. For example, here is a script certain to drive anybody crazy. With<br />

Wait(1), you probably want to interrupt execution before too long. If you change it to Wait(0), the<br />

iterations proceed faster than the speaking possibly can and the result sounds strange. On Windows, you<br />

can use a Wait(n) command to accomplish the same effect.<br />

for(i=99,i>0,i--,<br />

speak(wait(1),char(i)||" bottles of beer on the wall, "<br />

||char(i)||" bottles of beer; "<br />

||"if one of those bottles should happen to fall, "<br />

||char(i-1)||" bottles of beer on the wall. ")<br />

A more practical example has JMP announce the time every sixty seconds:<br />

// Time Announcer<br />

script = expr(<br />

tod = mod(today(),indays(1));<br />

hr = floor(tod/inHours(1));<br />

min = floor(mod(tod,inHours(1))/60);<br />

timeText = "time, " || char(hr) || " " || char(min);<br />

text = Long Date(today()) || ", " ||timeText;<br />

speak(text);<br />

);<br />

script;<br />

show(text);<br />

schedule(60,script);<br />

// seconds before next script<br />

You might use a similar technique to have JMP alert an operator that a process has gone out of control.<br />

Caption brings up a small window with a message to the viewer. Captions are a way to annotate<br />

demonstrations without adding superfluous objects to results windows. The first argument is an optional<br />

{x,y} screen location given in pixels from the upper left; the second argument is the text for the window. If<br />

the location argument is omitted, windows appear in the upper left corner.

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

Saved successfully!

Ooh no, something went wrong!