196
Chapter 14 Scripting the Visual Tools Object Model
Writing and Executing Scripts in Visual Tools
The Visual Tools expose an Object Model, enabling developers to manipulate
program functionality from external applications. In addition, power users can
create scripts to automate tasks using JScript or VBScript and run the scripts from
the Visual Tools environments.
The Visual Tools internal scripting feature requires the Microsoft ActiveScripting
engine version 3.1 or later, also known as Windows Script. The engine is not installed
with the Visual Tools. If you installed Microsoft Internet Explorer 4.0 or later on your
computer, then you have the correct ActiveScripting engine. Otherwise, you need to
download it from http://www.microsoft.com/msdownload/vbscript/scripting.asp.
The VTOM hierarchy
The object hierarchy is very simple; the Application object is the parent of all the
other objects and none of the other objects is a parent.
The VTOM hierarchy can be illustrated as follows:
Application
ActiveDocument
DocumentCache
Project
ProjectManager
DeploymentManager
HTTPProvider
ZIPProvider
Notation
The simplicity of the object model makes syntax notation very straightforward. To
call a property or method, begin at the object root, append the child object name (if
any), the property or method name, separated by a period, and then the parameters.
For example,
Application.ActiveDocument.SaveAs(Current ’\\’ + sFile);
Writing scripts
For a script to be executable from within the Visual Tools, it must contain a Main
routine. In JScript, create a function Main; in VBScript, create a Sub Main routine.
Without this routine, the script fails.
The program determines which language engine to use based on the extension of the
script file. If the file extension is BAS, VB, or VBS, the VBScript engine executes the
script. Otherwise, the program uses the JScript engine.
Содержание ColdFusion Server 5
Страница 18: ...xviii About This Book...
Страница 26: ...8 Chapter 1 Setting Up the Product...
Страница 42: ...24 Chapter 2 Configuring Browsers and Servers...
Страница 60: ...42 Chapter 3 Exploring the Workspace...
Страница 100: ...82 Chapter 6 Editing Pages...
Страница 126: ...108 Chapter 7 Using Web Development Languages...
Страница 212: ...194 Chapter 13 Customizing the Development Environment...
Страница 320: ...302 Glossary...