It is very important to understand the DocumentCache object when using the VTOM. Although the Visual Tools enable you to open dozens of files at once, only the active document stays in memory. When a document becomes inactive, that is, when the user switches to a different document in the Document window, the previously active document is cached to conserve resources.
Every open document has an element in the Application.DocumentCache array. To refer to a specific cached document, use Application.DocumentCache(Index), where Index is the index of the document in the Document tab.
//*********************************************//
//This JScript shows how to loop through the array:
//*******************************************//
var app = Application;
for (idx = 0; idx < app.DocumentCount; idx++) {
sFile = app.DocumentCache(idx).Filename;
}
//*********************************************//
//This VBScript shows how to loop through the array: //*******************************************// set app = Application for idx = 0 to app.DocumentCount - 1 sFile = app.DocumentCache(idx).Filename next
If you know the filename of an open document, you can retrieve its index by using the Application.GetTabIndexForFile function, like this:
var app = Application;
idx = app.GetTabIndexForFile('c:\docs\file.htm');
bReadOnly = app.DocumentCache(idx).ReadOnly;
To access more information about a cached document, you must first make it the active document and refer to it using the Application object's ActiveDocument property. To do this, set the Application.DocumentIndex property to the index of the cached document.
Filename: OleString (read-only)
Filename of the cached document.
function Main() {
var sMessage;
sMessage = "Your file name is: ";
with (Application) {
sMessage = sMessage + DocumentCache (0).Filename;
}
}
Modified: WordBool (read-only)
Boolean. Returns True if the cached document changed since it was last saved.
function Main() {
var sMessage;
sMessage = "Modified: ";
with (Application) {
If(DocumentCache (0).Modified)
sMessage = sMessage + "Yes";
Else
sMessage = sMessage + "No";
MessageBox(sMessage, VersionText, 0);
}
}
ReadOnly: WordBool (read-only)
Boolean. Returns True if the cached document is read-only.
function Main() {
var sMessage;
sMessage = "Read-only: ";
with (Application) {
If(DocumentCache (0).ReadOnly)
sMessage = sMessage + "Yes";
Else
sMessage = sMessage + "No";
MessageBox(sMessage, VersionText, 0);
}
}
Text: OleString (read-only)
File contents of the cached document.
function Main() {
var sMessage;
sMessage = "Your document contains the following text: \n";
with (Application) {
sMessage = sMessage + DocumentCache (0).Text;
}
}
LiveDocs comments are not longer enabled for ColdFusion 5.0. Please use one of the following resources instead.
ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 5.0