14 the onsessionreceive event, Syntax, Example – Casio Naurtech CETerm Ver.5.5 Scripting Guide User Manual
Page 95

N
AURTECH
W
EB
B
ROWSER AND
T
ERMINAL
E
MULATION FOR
W
INDOWS
CE
AND
W
INDOWS
M
OBILE
CETerm Scripting Guide
Page 95
{
// Check RF status
var status = CETerm.GetProperty ( "device.rf.status" );
if (status <= 0)
{
OS.Alert( "No RF signal detected.\n" +
"Return to RF coverage and reconnect." );
return;
}
// Attempt to reconnect to host
CETerm.PostIDA( "IDA_SESSION_CONNECT", session );
}
4.14
T
HE
O
N
S
ESSION
R
ECEIVE
E
VENT
The OnSessionReceive event is fired when a terminal emulation session
receives data from the connected host. The handler can be used to detect
screen content such as an error message and perform a desired action.
Syntax
function OnSessionReceive ( session, count )
session
– index of session which received data.
count
– count of bytes received.
Example
This example will check the screen content on line 24 looking for an error
message. If found, the error is displayed as a popup message.
/* OnSessionReceive */
function OnSessionReceive ( session, count )
{
// Get line of text
var s = CETerm.Session( session ).Screen;
var line = s.GetTextLine( 24 );
// Do a regular expression case-insensitive match
if (line.match( /error/i ))
{
OS.Alert( "Error: " + line );
}
}