Scripting Guide > Programming Methods > Writing to the Log > Send Information to the User
Publication date: 08/13/2020

Send Information to the User

Beep

Beep() causes the user’s computer to make an alert sound.

Speak

Speak() reads text aloud. On macOS, Speak() has one Boolean option, Wait(), to specify whether JMP should wait for speaking to finish before proceeding with the next step. The default is not to wait, and you need to issue Wait(1) each time. For example, here is a script certain to drive anybody crazy. With Wait(1), you probably want to interrupt execution before too long. If you change it to Wait(0), the iterations proceed faster than the speaking possibly can and the result sounds strange. On Windows, you can use a Wait(n) command to accomplish the same effect.

For( i = 99, i > 0, i--,
	Speak(
		Wait( 1 ),
		Char( i ) || " bottles of beer on the wall, " || Char( i ) || " bottles of beer; " ||
		"If one of those bottles should happen to fall, " || Char( i - 1 ) || " bottles of beer on the wall. "
	) );

A more practical example has JMP announce the time every sixty seconds:

script = Expr(
	tod = Mod( Today(), In Days( 1 ) );
	hr = Floor( tod / In Hours( 1 ) );
	min = Floor( Mod( tod, In Hours( 1 ) ) / 60 );
	timeText = "time, " || Char( hr ) || " " || Char( min );
	text = Long Date( Today() ) || ", " || timeText;
	Speak( text );
	Show( text );
	Schedule( 60, script );    // seconds before next script
);
script;

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

Caption

Caption() brings up a small window with a message to the viewer. Captions are a way to annotate demonstrations without adding superfluous objects to results windows. The first argument is an optional {h,v} screen location given in pixels from the upper left; the second argument is the text for the window. If the location argument is omitted, windows appear in the upper left corner.

You can include pauses in the playback by including the named argument Delayed and a time in seconds. Such a setting causes that caption and all subsequent caption windows to be delayed by that number of seconds, until a different Delayed setting is issued in a Caption statement. Use Delayed(0) to stop delaying altogether.

Specify the font type, font size, text color, or background color with the following arguments:

Font( font );
Font Size( size );
Text Color("color");
Back Color("color");

The Spoken option causes captions to be read aloud by the operating system’s speech system (if available). Spoken takes a Boolean argument, and the current setting (on or off) remains in effect until switched by another Caption statement that includes a Spoken setting.

This script turns speaking on and leaves it on until the last caption. In the first caption, the font type, color, and background color is specified. Run the script and notice that the font and color settings apply only to the first caption.

Caption(
	{10, 30},
	"A Tour of the JMP Analyses",
	Font( "Arial Black" ),
	Font Size( 16 ),
	Text Color( "blue" ),
	Back Color( "yellow" ),
	Spoken( 1 ),
	Delayed( 5 )
);
Caption( "Open a data table." );
bigClass = Open( "$SAMPLE_DATA/Big Class.jmp" );
Caption( "A data table consists of rows and columns of data." );
Caption( "The rows are numbered and the columns are named." );
Caption( {250, 50}, "The data itself is in the grid on the right" );
Caption(
	{5, 30},
	Spoken( 0 ),
	"A panel along the left side shows columns and other attributes."
);

Each new Caption hides the previous one. In other words, there is only one caption window available at a time. To close a caption without displaying a new one, use the named argument Remove.

Caption( remove );

StatusMsg

This command sends a message to the status bar.

StatusMsg( "string" );

Mail

Mail() sends an e-mail message to a user. For example, a process control manager might include a test alert script in a control chart to trigger an e-mail warning to her pager:

Mail(
	"JaneDoe@company.com",
	"out of control",
	"Process 12A out of control at " || Format( Today(), "d/m/y h:m:s" )
);

Mail() can also send an attachment with the e-mail. An optional fourth argument specifies the attachment. The attachment is transferred in binary format after its existence on the disk is verified. For example, to attach the Big Class.jmp data table, submit

Mail(
	"JohnDoe@company.com",
	"Interesting Data Set",
	"Have a look at this class data.",
	"$SAMPLE_DATA\Big Class.jmp" );

Note: On macOS, Mail() works on Mountain Lion and later operating systems. On Mountain Lion, you must enter the e-mail address and subject in the e-mail due to operating system limitations. Click the Send message button to send the e-mail.

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).
.