User manual - Scripting_Guide

NAURTECH SMART CLIENTS FOR WINDOWS CE AND POCKET PC
CETerm Scripting Guide Page 52
}
}
function RFWakeupSoundPlay()
{
// Select any wave file on device for notification.
CETerm.PlaySound( "infbeg" );
}
5.0 Scripting Techniques and Tips
This section describes ways that scripting can extend the capabilities of CETerm.
Tips for script development are also presented.
5.1 EXPECT AND EXPECTMONITOR FOR AUTOMATING TASKS
The “expect” script and “ExpectMonitor” class provide a general purpose
“prompt-and-response” tool. Using “expect” for automated login was described in
Section 2.6. Here we provide the complete listing of the scripts and discuss
other options for use.
5.1.1 Expect Script
The “expect” script illustrates a couple of powerful JavaScript constructs. Even
though the expect function has 4 defined arguments in the function declaration, it
is possible to pass an unlimited number of arguments. All arguments are
accessible through the special “arguments” variable. This script also shows the
object-oriented aspects of JavaScript by creating a new ExpectMonitor class.
/* expect */
//
// This script will "expect" a text prompt on the screen and
// respond with text or action.
//
// Syntax: expect( session, timeout,
// expectedText, response
// [,expectedText2, response2] )
//
// session is the session index
// timeout is the wait interval for each text in milliseconds
// expectedText can be a string or regular expression
// Response can be a text response or a function
function expect( session, timeout, expectedText, response )