User Guide

240
ActiveScripting examples
JScript
<html>
<head>
<title>JScript Example</title>
</head>
<body>
<pre>
//
//=====================================================================
// ActiveScripting example (JScript)
//=====================================================================
// Displays a table containing the filenames of all open documents,
// whether or not each document has been modified, and whether each
// document is read-only.
//=====================================================================
function Main() {
var newline = \n;
var br = <br>;
var tab = \t;
// create app reference. note that the Application object is only
// available from within HomeSite and Studio - to create the app
object from an
// external script, use
CreateObject(AllaireClientApp.TAllaireClientApp)
var app = Application;
// save the index of the current document so it can be returned to
var nCurrentIdx = app.DocumentIndex;
// start the table
var sTable = <b><font color=Blue>Names of all open
+ documents:</font></b>
+ br + newline + br + newline
+ <table border=1 width=460>
+ newline + <tr>
+ <td><b>Document</b></td>
+ <td><b>Modified</b></td>
+ <td><b>Read-Only</b></td>
+ </tr> + newline;
// loop through all open documents (note that DocumentCount is
1-based,
// whereas DocumentCache() is 0-based)
for (idx = 0; idx < app.DocumentCount; idx++) {
// get document name (uses function example)
fname = GetDisplayName(app.DocumentCache(idx).Filename);
sTable = sTable + tab + <tr><td> + fname;
sTable = sTable + </td><td>;