Scripting Guide

NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE
CETerm Scripting Guide Page 100
Example
This example will wait for RF coverage to resume and sound a tone when it is
available. While waiting, a “tic” sound will be made periodically to indicate the
check. This sample is more complex than needed, but it illustrates how to use
global variables and timers to periodically check state.
/* RFSoundOnConnect */
// Global control variables
var RFWakeupSoundTimerID = 0;
var RFWakeupSoundContinue = 0;
var RFWakeupSoundInterval = 200; // milliseconds
var RFWakeupSoundCountMaximum = 50; // 50*200 = 10 seconds
var RFWakeupSoundCount = 0;
function OnWakeup ()
{
// Start with wakeup event
RFWakeupSoundStart();
}
// Function to start RF check
function RFWakeupSoundStart()
{
if (!RFWakeupSoundContinue)
{
RFWakeupSoundContinue = 1;
if (RFWakeupSoundTimerID != 0)
{
// Stop and clear any previous check
CETerm.ClearTimeout( RFWakeupSoundTimerID );
RFWakeupSoundTimerID = 0;
}
RFWakeupSoundCount = 0;
// Schedule first RF check
RFWakeupSoundTimerID = CETerm.SetTimeout(
"RFWakeupSoundOnTimer();",
RFWakeupSoundInterval );
}
}
// Function to check RF and notify user
function RFWakeupSoundOnTimer()
{
RFWakeupSoundTimerID = 0;
RFWakeupSoundCount++;
// Get and check info
var rfStatus = CETerm.GetProperty( "device.rf.status" );