Casio Naurtech CETerm Ver.5.5 Scripting Guide Manual do Utilizador Página 102

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 164
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 101
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 )
{
// 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;
Vista de página 101
1 2 ... 97 98 99 100 101 102 103 104 105 106 107 ... 163 164

Comentários a estes Manuais

Sem comentários