User manual - Scripting_Guide

NAURTECH SMART CLIENTS FOR WINDOWS CE AND POCKET PC
CETerm Scripting Guide Page 53
{
// Build array from arguments
// This technique will accumulate any
// number of expect/response pairs
var TargetResponseArray = [];
for (var i=2; i < arguments.length; i++)
{
TargetResponseArray.push( arguments[i] );
}
// Create an ExpectMonitor class that manages the actions
var EM = new ExpectMonitor( session, timeout,
TargetResponseArray );
// Set optional ExpectMonitor behaviors
//EM.silent = true;
//EM.OnDone = function (success) { OS.Alert( "Done." ) };
// Start check
EM.Start();
}
5.1.2 ExpectMonitor Class
The “ExpectMonitor” class illustrates the use of a prototype in JavaScript. This
class also manages all instances of itself to restrict the number of objects that
can be created.
/* ExpectMonitor */
//
// ExpectMonitor class
//
// The ExpectMonitor class manages the expect/action
// sequence for a session.
// Only one ExpectMonitor is allowed per session.
//
function ExpectMonitor( session, timeout, targetactions )
{
// Validate session
if (session < 1 || session > 4)
{
return null;
}
this.session = session;
this.timeout = timeout;
this.args = targetactions;