Writing And Executing Scripts In Allaire Visual Tools - MACROMEDIA COLDFUSION STUDIO 4.5-USING COLDFUSION STUDIO Use Manual

For windows 95/98/nt4/2000
Table of Contents

Advertisement

192

Writing and Executing Scripts in Allaire Visual Tools

The Allaire visual tools — HomeSite, ColdFusion Studio, and JRun Studio — expose an
Object Model, enabling developers to manipulate program functionality from external
applications. In addition, power users can create scripts using JScript or VBScript and
execute them from within the visual tools environments to automate tasks.
The internal scripting feature requires Microsoft's ActiveScripting engine v3.1 or later,
also known as Windows Script. The engine is not installed with the Allaire visual tools.
If you have Microsoft Internet Explorer 4.0 or later on your system, then you have the
correct ActiveScripting engine installed. Otherwise, you need to download it from
http://www.microsoft.com/msdownload/vbscript/scripting.asp.
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. 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, then the VBScript engine is used to
execute the script. Otherwise, it is assumed that the file contains JScript source.
To automate visual tools tasks, you will need to familiarize yourself with the Visual
Tools Object Model. The main object is the Application object. The Application object
contains two important child objects, the ActiveDocument object and the
DocumentCache object. You can use these to write scripts for common tasks.
In addition, the Application object contains a number of toolbar-related functions,
enabling you to create toolbars dynamically.
For best performance, you should create an Application object variable and use it
throughout the script rather than continually referencing the Application object
directly.
For example, using JScript:
function Main() {
}
or VBScript:
Sub Main
End Sub
Note
var app = Application; //create application object variable
app.WindowState = 2; //maximize the window
Dim app
set app = Application 'create application object variable
app.WindowState = 2 'maximize the window
The Application object is only available from scripts that are executed
within the visual tools. To access the Application object from an external
program, use your language's equivalent of
CreateObject("AllaireClientApp.TAllaireClientApp"
).

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion studio 4.5

Table of Contents