User manual - Scripting_Guide

NAURTECH SMART CLIENTS FOR WINDOWS CE AND POCKET PC
CETerm Scripting Guide Page 60
The following example will save data from memory to a flash file whenever a
particular URL is loaded.
/* OnDocumentDone */
function OnDocumentDone( session )
{
var b = CETerm.Session( session ).Browser;
if (b.Document.URL.match( /InventorySave/ ))
{
// Resume online inventory, and save cached
// data to file in background.
CETerm.SetTimeout( "BackgroundSave(" + session + ");", 10 );
}
}
/* BackgroundSave */
function BackgroundSave( session )
{
var d = new ActiveXObject( "Microsoft.XMLDOM" );
d.loadXML(
"<?xml version=\"1.0\"?><Books>" +
"<Book QTY=\"10\"><Title>Beginning XML</Title></Book>" +
"<Book QTY=\"2\"><Title>Mastering XML</Title></Book>" +
"</Books>");
if (!OS.File.Write( "\\FlashDisk\\inventory.xml", d.xml ))
{
OS.Alert( "Failed to save inventory." );
}
}
5.6 ACCESSING A FILE
The File automation object provides basic access to the Windows CE filesystem.
It supports whole-file read and write, but does not support the concept of an
“open” file with piecewise read or write. You can also create and delete file
directories.
This example shows how to append to an existing file by using a combination of
read and write.
/* AppendToFile */
function AppendToFile( filename, addedContent )
{
var status = false;