Application Object

You can script the Application object's child objects to perform common tasks and to create toolbars dynamically.

Properties

ActiveDocument

Syntax

ActiveDocument: object (read-only) 

Description

The active document. For details, see "ActiveDocument Object".

ApplicationType

Syntax

ApplicationType: integer (read-only) 

Description

The current application type.

Sample ApplicationType script

//**********************************//
// Tests Application.ApplicationType property
// 0 = HomeSite
// 1 = CF Studio
// 2 = JRun Studio
//********************************//
function Main(){
  var iAppType;
  var sMessage;
  
  with (Application) {
    if (IsColdFusionStudio)
      MessageBox('IsColdFusionStudio returns True', 
'Application Type', 0)
    else
      MessageBox('IsColdFusionStudio returns False', 
'Application Type', 0);
  iAppType = ApplicationType;
    switch(iAppType) {
            case 0: {
                sMessage = 'HomeSite';
                break;
            }
            case 1: {
                sMessage = 'ColdFusion Studio';
                break;
            }
            case 2: {
                sMessage = 'JRun Studio';
                break;
            }
            default: {
                sMessage = 'an unknown application type';
            }
        }        MessageBox('You are enjoying ' + sMessage + '.', 
'Application Type', 0);            
}

AppPath

Syntax

AppPath: OleString (read-only) 

Description

Path to application executable.

Example

function Main() {
var sPath;

with (Application) {
     sPath = AppPath; // Store the path in a variable 
}
}

CurrentFolder

Syntax

CurrentFolder: OleString 

Description

Path currently displayed in the local file list.

Example

function Main(){
  with (Application){
    CurrentFolder = 'C:\\InetPub\\wwwroot';
  }
}

CurrentView

Syntax

CurrentView: ITCurrentViewType 

Description

Sets/gets the current view.

The following values are allowed:

1 - vwEditSource
2 - vwPreview (browse)
3 - vwHelp

The value 3 applies only if the Help tab is already visible in the application.

Example

function Main() {
with (Application){
     CurrentView = 2; // Set the view to Browse
}
}

Sample CurrentView script

//**********************************************************//
//  This script switches the views inside the application
//*********************************************************//
function Main () {
var sMessage;

with (Application) {
     
   CurrentView = 1;
   sMessage = "You are now in Edit View of your " + 
VersionText;
   MessageBox (sMessage, VersionText, 0);
   
   CurrentView = 2;
   sMessage = "You are now in Browse View of your " + 
VersionText;
   MessageBox (sMessage, VersionText, 0);
   
   CurrentView = 3;   
   sMessage = "You are now in Help View of your " + 
VersionText;
   MessageBox (sMessage, VersionText, 0);
  }
}

DocumentCache

Syntax

DocumentCache: array of objects (read-only) 

Description

For details, see "DocumentCache Object" .

Example

function Main(){
  with (Application){
    // Save the first document
    if (DocumentCache(0).Modified){
      DocumentIndex = 0;
      ActiveDocument.Save();
    }
  }
}

DocumentCount

Syntax

DocumentCount: integer (read-only) 

Description

Number of open documents.

Example

function Main() {
Var sMessage;

with (Application){
     sMessage = "There are ";
     sMessage = sMessage + sDocumentCount + " open.\n";      
// Get the number of open documents.            
     sMessage = sMessage + sDocumentIndex + ".\n";       
// Get the index of the current document.
}
}

DocumentIndex

Syntax

DocumentIndex: Integer 

Description

Tab index of current document.

Example

function Main() {
Var sMessage;

with (Application){
     sMessage = "There are ";
     sMessage = sMessage + sDocumentCount + " open.\n";      
// Get the number of open documents.            
     sMessage = sMessage + sDocumentIndex + ".\n";       
// Get the index of the current document.
}
}

ExeName

Syntax

ExeName: OleString (read-only) 

Description

File name of application executable, including path.

Example

function Main() {
Var sExeName;

with (Application){
    sExeName = ExeName;  // Store the path in a variable
}
}

Height

Syntax

Height: integer 

Description

Height in pixels of main window.

Example

function Main() {
Var sMessage;

with (Application){
     sMessage = "Top-left corner of your Window has the 
following coordinates: \n";
     sMessage = sMessage + "Top: " + Top + "\n";        
// Get top
     sMessage = sMessage + "Left: " + Left + "\n\n";    
// Get left       
     sMessage = sMessage + "And the following measurements: \n"
     sMessage = sMessage + "Width: " + Width + "\n";    
// Get Width
     sMessage = sMessage + "Height: " + Height + "\n";  
// Get Height
}
}

HInstance

Syntax

HInstance: integer (read-only) 

Description

Instance handle of the application.

hWnd

Syntax

hWnd: integer (read-only) 

Description

Handle to the main window.

IsColdFusionStudio

Syntax

IsColdFusionStudio: WordBool (read-only) 

Description

Boolean. Returns True if the application is ColdFusion Studio or JRun Studio, False if HomeSite.

Example

function Main(){
  with (Application){
    if (IsColdFusionStudio){
      // Show CF Advanced toolbar
      ShowToolBar('CFML Advanced');      
    }
  }
}

Left

Syntax

Left: integer 

Description

Left (x-coordinate) of main window.

Example

function Main() {
Var sMessage;

with (Application){
     sMessage = "Top-left corner of your Window has the following coordinates: \n";
     sMessage = sMessage + "Top: " + Top + "\n";        
// Get top
     sMessage = sMessage + "Left: " + Left + "\n\n";    
// Get left       
     sMessage = sMessage + "And the following measurements: \n"
     sMessage = sMessage + "Width: " + Width + "\n";    
// Get Width
     sMessage = sMessage + "Height: " + Height + "\n";  
// Get Height
}
}

ResourceTabShowing

Syntax

ResourceTabShowing: WordBool 

Description

Boolean. Specifies whether the resource tab displays.

Example

function Main(){
  with (Application){
    // Toggle resource tab on/off
    ResourceTabShowing = !ResourceTabShowing;
  }
}

ResultsShowing

Syntax

ResultsShowing: WordBool 

Description

Boolean. Specifies whether the results tab displays.

Example

function Main() {
with (Application){
      If (ResultShowing)
   ResultShowing = false;   
//If the result bar is showing - hide it
      Else
   ResultShowing = true;    
//Hide it otherwise
}
}

Top

Syntax

Top: integer 

Description

Top (y-coordinate) of main window.

Example

function Main() {
Var sMessage;

with (Application){
     sMessage = "Top-left corner of your Window has the following coordinates: \n";
     sMessage = sMessage + "Top: " + Top + "\n";        
// Get top
     sMessage = sMessage + "Left: " + Left + "\n\n";    
// Get left       
     sMessage = sMessage + "And the following measurements: \n"
     sMessage = sMessage + "Width: " + Width + "\n";    
// Get Width
     sMessage = sMessage + "Height: " + Height + "\n";  
// Get Height
}
}

VersionText

Syntax

VersionText: OleString (read-only) 

Description

Application name and version.

Example

function Main() {
Var sMessage;

with (Application){
     If (IsColdFusionStudio){
         sMessage = "You are running ColdFusionStudio - " + 
VersionText;
         MessageBox(sMessage,"Sample",0);
    }
     Else{
         sMessage = "You are running HomeSite - " + 
VersionText;
         MessageBox("You are Running HomeSite", "Sample", 0);
    }
}
}

Width

Syntax

Width: integer 

Description

Width in pixels of the main application window. Use this property with the Height property to return the size of the main window as well as to resize the window.

WindowState

Syntax

WindowState: integer 

Description

Set and get window state.

The following values are allowed:

0 - Normal
1 - Minimized
2 - Maximized

Example

function Main(){
  var iNormal   = 0;
  var iMinimized   = 1;
  var iMaximized  = 2;
  
  with (Application){
    // Toggle through all window states
    WindowState = iMaximized;
    Wait(1000);
    WindowState = iMinimized;
    Wait(1000);
    WindowState = iNormal;
  }
}

Methods

BringToFront

Syntax

BringToFront(); 

Description

Brings the main window to the front of other applications.

Example

function Main() {
with (Application){
     BringToFront();
}
}

BrowseText

Syntax

BrowseText(sText, BaseHREF: OleVariant); 

Description

Displays the passed text in the internal browser. Use the BaseHREF parameter to interpret relative paths. For local files, BaseHREF is the folder that contains the file.

Example

function Main() {
Var sMessage;

sMessage = "You are viewing this text in the browse mode of your "; 
sMessage = sMessage + VersionText;

with (Application){
     BrowseText (sMessage);       
}          
}

CloseAll

Syntax

CloseAll(wbPromptToSave: WordBool): WordBool; 

Description

Closes all open documents. If wbPromptToSave is True, the user is prompted to save any changes. Returns True if successful, that is, the user didn't cancel if wbPromptToSave is True.

Example

function Main() {
with (Application){
     CloseAll();  
}
}

ExecCommand

Syntax

ExecCommand(nCmdID: integer, nOptions: integer); 

Description

Boolean. Execute a specific command based on its CommandID. For available commands, see "Table of CommandID Values". Use nOptions with cursor movement commands to determine whether text is selected during cursor movement (nOptions = 1) or unselected (nOptions = 0). For all other commands, pass nOptions = 0.

Example

function Main() {
with (Application){
     ExecCommand(3); // Executes an Open File command.
}
}

ExtractFileName

Syntax

ExtractFileName(const wsFile: WideString): WideString; 

Description

Returns only the file portion of the passed file name.

Example

function Main() {
Var sFullFilePath;
Var sFileName;

sFullFilePath = "C:/Temp/MyScript.js"

with (Application){
     sFileName = ExtractFileName(sFullFilePath); 
// Returns 'MySript.js'
}
}

ExtractFilePath

Syntax

ExtractFilePath(const wsFile: WideString): WideString; 

Description

Returns the path of the passed file (includes trailing '\').

Example

function Main() {
Var sFilePath;
Var sFullFilePath;

sFullFilePath = "C:/Temp/MyScript.js" 

with (Application){
     sFilePath = ExtractFilePath(sFullFilePath); 
// Returns 'C:/Temp/'
}
}

GetApplicationSetting

Syntax

GetApplicationSetting(nSettingID: Integer); 

Description

Retrieves a specific application setting based on a SettingID.

Example

function Main(){
  var SET_CLOSE_PARA_TAGS = 80;

  with (Application){
    if (GetApplicationSetting(SET_CLOSE_PARA_TAGS) == 0){
      ActiveDocument.InsertText('<p>', false);
    }
    else {
      ActiveDocument.InsertText('<p></p>', false);
    }
  }
}

GetImageHeight

Syntax

GetImageHeight(const wsImageName: WideString): Integer; 

Description

Returns the height in pixels of the passed image. Returns 0 on error.

Example

/*  
  Tests GetImageHeight, GetImageWidth
  Looks for first GIF image in current directory
*/

function Main(){
  with (Application) {
    aFileObj  = new ActiveXObject("Scripting.FileSystemObject");
    aFolder    = aFileObj.GetFolder(CurrentFolder);
    aFiles    = new Enumerator(aFolder.files);
    sExtToTest  = 'gif';
    sFile    = '';

    for (; !aFiles.atEnd(); aFiles.moveNext()){
      if (aFileObj.GetExtensionName(aFiles.item()) 
== sExtToTest){
        sFile = aFiles.item();
        break;
      }
    }
    
    if (!sFile == ''){
      sMsg = sFile + '\n\n' + 'Height = ' + 
GetImageHeight(sFile) + '\n';
      sMsg = sMsg + 'Width = ' + GetImageWidth(sFile);
      MessageBox(sMsg, 'GetImageHeight/Width Test', 0);
    }
    else{
      MessageBox('No images found in current directory', 'GetImageHeight/Width Test', 0);
    }
  
}

GetImageSize

Syntax

GetImageSize(const wsImageFile: WideString; var nHeight, 
nWidth: Integer): WordBool; 

Description

Boolean. Retrieves the size of the passed image. Returns False on error.

Example

function Main() {
Var sFullImagePath;
Var Height;
Var Width;

sFullImagePath = "C:/Temp/photos/MyPic.jpg"; 

with (Application){
     sFilePath = GetImageSize(sFullImagePath,Height,Width); 
//Store the image parameters in Height and Width

}
}

GetImageWidth

Syntax

GetImageWidth(const wsImageName: WideString):Integer; 

Description

Returns the width in pixels of the passed image. Returns 0 on error.

Example

See the GetImageHeight example.

GetMemoryStatus

Syntax

GetMemoryStatus(iMemType); 

Description

Returns an integer value. On Windows 98, the values for 0, 1, and 2 are real numbers. On Windows NT, since there is no corresponding API call to get resource levels, these types always return the value 80%.

The following values are allowed:

0 - Available System resources    (%)
1 - Available GDI resources    (%)
2 - Available User resources    (%)
3 - General memory used    (%)
4 - Total physical memory    (bytes)
5 - Available physical memory    (bytes)
6 - Total swap file storage space    (bytes)
7 - Available swap file storage space    (bytes)
8 - Total virtual space    (bytes)
9 - Available virtual space    (bytes)

GetRelativePath

Syntax

GetRelativePath(const wsBaseURL, wsFolderURL: WideString): WideString; 

Description

Returns the relative path of a folder given a base URL. For example,

GetRelativePath ("http://www.macromedia.com/", "http://www.macromedia.com/software/")

returns "products/".

Example

function Main() {
Var sFullPath1;
Var sRelativePath;
Var sFullPath2;

sFullPath1 = "http://www.macromedia.com/";
sFullPath2 = "http://www.macromedia.com/software";

with (Application){
     sRelativePath = GetRelativePath (sFullPath1,sFullPath12);
}
}

GetTabIndexForFile

Syntax

GetTabIndexForFile(const wsFile: WideString): Integer; 

Description

Returns the index in the document tab of the passed file. Returns -1 If the file is not open.

Example

function Main(){
  var  iIndex;
  
  with (Application){

    // Switch to index.htm if it is open  
    iIndex = GetTabIndexForFile('D:\\Test\\index.html');
    if (iIndex > 0){
      DocumentIndex = iIndex;
    }
  }
}

GetURL

Syntax

GetURL(const wsURL: WideString): WideString; 

Description

Retrieves a URL and returns its contents.

Example

function Main() {
Var sURL;
Var sContents;

sURL = "http://www.macromedia.com/";

with (Application){
      sContents = GetURL(sURL);  
// Storing HTML code of the URL in sContents
}
}

GetURLResponse

Syntax

GetURLResponse(const wsURL: WideString): WideString; 

Description

Retrieves a URL and returns its contents.

Example

/*  
  Tests GetURLResponse, GetURLStatusCode
*/

function Main(){
  with (Application) {
    sURL_1  = 'http://www.macromedia.com';
    sURL_2  = 'http://www.this_should_not_exist.com';
    
    sResponse   = GetURLResponse(sURL_1);
    iStatus    = GetURLStatusCode(sURL_1);
    
    sMsg = 'URL:  ' + sURL_1 + '\n\n';
    sMsg = sMsg + 'Response: ' + sResponse + '\n';
    sMsg = sMsg + 'Status:   ' + iStatus;
    
    MessageBox(sMsg, 'GetURLResponse/StatusCode Test', 0);
    
    sResponse   = GetURLResponse(sURL_2);
    iStatus    = GetURLStatusCode(sURL_2);
    
    sMsg = 'URL:  ' + sURL_2 + '\n\n';
    sMsg = sMsg + 'Response: ' + sResponse + '\n';
    sMsg = sMsg + 'Status:   ' + iStatus;
    
    MessageBox(sMsg, 'GetURLResponse/StatusCode Test', 0);
    
  }
}

GetURLStatus

Syntax

GetURLStatus(const wsURL: WideString; 
var vResponse: OleVariant): Integer; 

Description

Returns the HTTP status code for the passed URL. The text of the server response is returned in the second parameter.

GetURLStatusCode

Syntax

GetURLStatusCode(const wsURL: WideString): Integer; 

Description

Returns the status code for the passed URL.

Example

See the GetURLResponse example.

HideProgress

Syntax

HideProgress(); 

Description

Hides the progress bar.

Example

function Main() {
with (Application){
      HideProgress();   // Hides the progress bar
}
}

HTMLConvertTagCase

Syntax

HTMLConvertTagCase(const wsHTML: WideString; 
const wbUpperCase: WordBool): WideString; 

Description

Boolean. Converts the case of the passed HTML string. Retains the contents of script, style or comment tags, and retains the case of attribute values.

Example

function Main() {
Var sSource;

with (Application) {
      
if (HTTPProvider.State == 0){
    
  HTTPProvider.URL = InputBox(VersionText, "Please Enter the URL.", "http://www.yahoo.com"); 
  HTTPProvider.Get();    // Perform HTTP Get Request
  sSource = '';
  NewDocument (false);   //Open a new document inside the currently utilized application
  sSource = GetURL(sURL); 
        sSource = HTMLConvertTagCase (sSource, true); 
// Converting the tags to upper case.
    }
}
}

HTMLGetAttribute

Syntax

HTMLGetAttribute(const wsInTag, wsAttr: WideString): WideString; 

Description

Returns the value for a particular attribute of a tag. For example,

HTMLGetAttribute("&lt;TABLE WIDTH=100&gt;", "WIDTH");

returns 100.

Example

function Main(){
  var sWidth;
  
  with (Application){
    // Get width attribute of a table tag
    sWidth = HTMLGetAttribute("<table width=100>", "width");
  }
}

HTMLGetTitle

Syntax

HTMLGetTitle(const wsFile: WideString): WideString; 

Description

Returns the contents of an HTML file's title tag. This only operates on local files.

Example

function Main() {
Var sFile;
Var sTitle;
sFile = "C:\\Temp\index.html";

with (Application) {
     
     sTitle = HTMLGetTitle (sFile);   
// Store the contents inside <INDEX> in sTitle

}
}

InputBox

Syntax

InputBox(const wsCaption, wsPrompt, wsDefault: WideString): WideString; 

Description

Displays a dialog box for obtaining user input.

Example

function Main() {
Var sInput;
Var sOutput;

with (Application) {
     sInput = InputBox(VersionText, "What is your name?", "Alex");   
     sOutput  = "I know you, your name is " + sInput + ".";
     MessageBox (sOutput, VersionText, 0);        
}
}

IsFileOpen

Syntax

IsFileOpen(sFile: OleVariant): WordBool; 

Description

Boolean. Returns True if the passed file is open in the Document tab.

Example

function Main(){
  sFile = 'D:\\Test\\index.html';

  with (Application){
    if (!IsFileOpen(sFile)){
      OpenFile(sFile);
    }
  }
}

IsFileModified

Syntax

IsFileModified(sFile: OleVariant): WordBool; 

Description

Boolean. Returns True if the passed file is open in the Document tab and was modified.

Example

function Main(){
  with (Application){
    // Save current file if it is modified
    if (IsFileModified(ActiveDocument.FileName)){
      ActiveDocument.Save();
    }
  }
}

InstallParserScript

Syntax

InstallParserScript(const wsScriptFile, wsFileExtAssoc: WideString): WordBool; 

Description

Boolean. Returns False on error. Installs a parser (color-coding) script and associates it with the passed list of semicolon-separated file extensions. If an existing parser is assigned to any of these extensions, they are removed from the existing parser and assigned to the new one. The parser script is copied from the passed location to the application \Parsers subdirectory.

Example

function Main(){
  with (Application){
    InstallParserScript('D:\\Download\\XHTML_2.scc', 'xhtml');
  }
}

LogMemoryStatus

Syntax

LogMemoryStatus(const wsLogFile, wsDescrip: WideString); 

Description

Writes the current memory status to a log file, wsLogFile: logfilename. Creates the file if it does not exist, otherwise appends status to the file. The description text for the entry is entered in wsDescrip: text .

Example

function Main(){
  with (Application){
    LogMemoryStatus('D:\\Test\\MemLog.txt', 'Application Start');
  }
}

MessageBox

Syntax

MessageBox(const wsText, wsCaption: WideString, nType: Integer): 
Integer; 

Description

Displays a message dialog box for obtaining a user response. The nType parameter determines the type of dialog box displayed, and uses a combination of the following sets of values:

MB_ICONINFORMATION = 64
MB_ICONWARNING = 48
MB_ICONQUESTION  = 32
MB_ICONSTOP  = 16
MB_ABORTRETRYIGNORE  = 2
MB_OK = 0 (Default)
MB_OKCANCEL = 1
MB_RETRYCANCEL = 5
MB_YESNO = 4
MB_YESNOCANCEL = 3

The function's result contains the ID of the button that the user clicked.

The following ID values are allowed:

IDOK = 1
IDCANCEL = 2
IDABORT = 3
IDRETRY = 4
IDIGNORE = 5
IDYES = 6
IDNO = 7
IDCLOSE = 8

Example

function Main() {
Var sInput;
Var sOutput;

with (Application) {
     sInput = InputBox(VersionText, "What is your name?", "Alex");   
     sOutput  = "I know you, your name is " + sInput + ".";
     MessageBox (sOutput, VersionText, 0);        
}  
}

NewDocument

Syntax

NewDocument(wbUseDefaultTemplate: WordBool); 

Description

Boolean. Creates a new document, optionally from the default template.

Example

function Main(){
  with (Application){
    NewDocument(true);
  }
}

OpenFile

Syntax

OpenFile(const wsFile: WideString): WordBool; 

Description

Boolean. Opens the passed file. Returns if the file opens or is already open. Passing an empty string to OpenFile displaysthe Open File dialog box, which enables the user to select the files to open.

When using this method in JScript, you must escape backslashes inside a string. For example, in Application.OpenFile("C:\\Documents\\MyFile.htm"); each backslash is preceded by an additional backlash.

Example

function Main() {
Var sFile;
Var bResult;

sFile = "C:\\Temp\myDoc.txt"

with (Application) {
      If(OpenFile(sFile))
  MessageBox("File opened successfuly.", VersionText);
      Else     
  MessageBox("File does not exist or already open.", VersionText);
}
}

NextDoc

Syntax

NextDoc(); 

Description

Moves to the next document in the Document tab. If the last document is showing, wraps to the first.

Example

function Main() {
Var sMessage;

sMessage = "Hello world!";

with (Application) {
     NewDocument(false);                 
     NextDoc();           
     ActiveDocument.InsertText(sMessage);   // Moving to the newly-created document
}
}

PreviousDoc

Syntax

PreviousDoc(); 

Description

Moves to the previous document in the Document tab. If the first document is showing, wraps to the last.

Example

function Main(){
  with (Application){
    // Create a new blank document
    NewDocument(false);
    // Move back to previous file
    PreviousDoc();
  }
}

Quit

Syntax

Quit(); 

Description

This method attempts to exit from or quit the program. It prompts the user to save any unsaved documents prior to quitting.

Example

function Main(){
  var MB_YESNO = 4;
  var IDYES   = 6;
  
  with (Application){
    if (MessageBox('Exit HomeSite?', 'Confirmation Message', 
MB_YESNO) == 6){
      Quit();
    }
  }
}

RunCodeSweeper

Syntax

RunCodeSweeper(); 

Description

Runs the CodeSweeper on the active document using the active CodeSweeper. To change the active CodeSweeper, use SetActiveCodeSweeper.

Example

function Main() {
with (Application) {
     RunCodeSweeper ();
}
}

SaveAll

Syntax

SaveAll(): WordBool; 

Description

Boolean. Saves all open documents. Returns True if successful.

Example

function Main() {
with (Application) {
     SaveAll ();
}
}

SaveResultsToFile

Syntax

SaveResultsToFile(const wsFile): WideString; 

Description

Saves the contents of the active Results window to the named file.

Example

function Main() {
with (Application) {
     SaveResultsToFile();
}
}

SendToBack

Syntax

SendToBack(); 

Description

Sends the main window to the back of other applications.

Example

function Main() {
with (Application) {
     SendToBack ();
}
}

SetActiveCodeSweeper

Syntax

SetActiveCodeSweeper(const wsFileName: WideString): WordBool; 

Description

Changes the active CodeSweeper format file.

Example

function Main(){
  var sCS_File = 'C:\\Program Files\\Macromedia\\ColdFusion Studio 5\\Extensions\\CodeSweepers\\WebXML.vtm';

  with (Application){
    SetActiveCodeSweeper(sCS_File);
  }
}

SetActiveResults

Syntax

SetActiveResults(resType: TCurrentResultsType); 

Description

Boolean. Sets the active page in the Results tab.

The following values are allowed:

resSearch
resValidator
resLinks
resThumbnails

Example

function Main() {
with (Application) {
     SetActiveResults ();
}
}

SetApplicationSetting

Syntax

SetApplicationSetting(nSettingID: Integer ovSettingVal: OleVariant); 

Description

Sets a specific application setting based on its SettingID.

Example

function Main(){
  var SET_EDITOR_FONTNAME  = 300;

  with (Application){
    SetApplicationSetting(SET_EDITOR_FONTNAME, 'Lucida Console');
  }
}

SetFileTabFolder

Syntax

SetFileTabFolder(iTab: integer; sFolder: string); 

Description

Sets the active folder for each of the Files tabs.

Example

function Main(){
  var sFolder1    = 'C:\\Program Files\\Bradbury\TopStyle2';
  var sFolder2    = 'C:\\InetPub\\wwwroot';

  with (Application) {
        SetFileTabFolder(1, sFolder1);
        SetFileTabFolder(2, sFolder2);
  }
}

SetProgress

Syntax

SetProgress(nProgress: Integer); 

Description

Sets the position of the progress bar in the status area.

The following values are allowed:

1-100.

Example

function Main() {
with (Application) {
     SetProgress (15);
}
}

SetStatusText

Syntax

SetStatusText(sMessage: OleString); 

Description

Sets the text that displays in the status area.

Example

function Main() {
with (Application) {
      SetStatusText("Progress Indicator: ");
}
}

ShellToApp

Syntax

ShellToApp(const wsAppFileName: WideString): WordBool; 

Description

Executes an external application. Returns True if application launched successfully. You can include command lines in the file name parameter, so the following syntax is valid:

Application.ShellToApp("notepad.exe " + Application.ActiveDocument.Filename)

ShellToAppAndWait

Syntax

ShellToAppAndWait(const wsAppFileName: WideString); 

Description

Boolean. Same as ShellToApp but waits for the external program to close before returning. The application is locked until ShellToAppAndWait returns, so use this method with caution.

Example

function Main(){
  with (Application){
    // Edit current document in notepad and then reload it
    ShellToAppAndWait('notepad.exe ' + ActiveDocument.Filename);
    ActiveDocument.Reload(false);
  }
}

ShowProgress

Syntax

ShowProgress(); 

Description

Shows the progress bar.

Example

function Main() {
with (Application) {
      ShowProgress();
}
}

ShowThumbnails

Syntax

ShowThumbnails(sFolder: OleString); 

Description

Shows thumbnails for all images in the passed folder.

Example

function Main(){
  with (Application){
    ShowThumbnails(CurrentFolder);
  }
}

StatusError

Syntax

StatusError(const wsMsg: WideString); 

Description

Displays an error message in the status bar. Message appears on a red background and displays for at least 5 seconds.

Example

function Main(){
  with (Application){
    if (ActiveDocument.Modified){
      StatusError('Current document is modified');
    }
  }
}

StatusWarning

Syntax

StatusWarning(const wsMsg: WideString); 

Description

Displays a warning message in the status bar. Message appears on a blue background and displays for at least 5 seconds.

Example

function Main(){
  with (Application){
    if (ActiveDocument.ReadOnly){
      StatusWarning('Current document is read-only');
    }
  }
}

TagCase

Syntax

TagCase(const wsTag: WideString): WideString; 

Description

Changes the case of the passed string based on the "Lowercase all inserted tags" setting in the HTML panel in the Options > Settings dialog box. Does not modify the case of attribute values.

Example

function Main(){
  with (Application){
    ActiveDocument.InsertText(TagCase('<a href="http://www.macromedia.com"'), false);
  }
}

ToolbarDir

Syntax

ToolbarDir: WideString (read-only); 

Description

Returns the path where toolbar files are located.

Example

function Main(){
  with (Application){
    CurrentFolder = ToolbarDir;
  }
}

Wait

Syntax

Wait(nMilliseconds: Integer); 

Description

Pauses for given number of milliseconds. Use Wait to enable scripts to execute loops yet still allow access to the UI. Without the call to Wait in the loop, the application appears locked and the user cannot change views.

Example

The following JScript sample waits for the user to return to edit source view:
var app = Application;
while (app.CurrentView != 1) {
  app.Wait(100);            
}

This is the same sample code in VBScript:

set app = Application
while app.CurrentView  1
  app.Wait (100)
wend        

Toolbar and toolbutton methods

This section contains the toolbar manipulation methods available in the Application object, grouped together for easy reference.

A unique name identifies each toolbar. The name of the toolbar displays in the title bar caption when the toolbar is not docked. Toolbars are loaded from files in the toolbar directory, which can be obtained from the ToolbarDir property. The toolbar name is the same as its file name without the path or extension. For example, if the toolbar file name is Custom.tbr, then the toolbar name is Custom.

When you create a toolbutton, remember that a toolbutton label is limited to two characters.

AddAppToolbutton

Syntax

AddAppToolbutton(wsToolbarName, wsExeFile, wsCmdLine, wsHint: Wide-String): WordBool; 

Description

Boolean. Adds a toolbutton for an external application to the passed toolbar. Fails if the toolbar does not exist or if the toolbutton could not be added. Returns True if the same toolbutton (based on wsExeFile and wsCmdLine) already exists on the toolbar, but does not add a duplicate button.

Example

function Main(){
  with (Application){
    AddAppToolbutton('Standard', 'Notepad.exe', '', 'NotePad');
  }
}

AddScriptToolbutton

Syntax

AddScriptToolbutton(wsToolbarName, wsScriptFile, wsHint, wsCaption, wsImageFile: WideString): WordBool; 

Description

Boolean. Adds a script toolbutton (executes passed JScript or VBScript file when clicked) to the passed toolbar. Fails if toolbar does not exist. Returns True if a toolbutton already exists, but does not add a duplicate button.

Example

function Main() {
Var sToolBarName = "MyToolBar";

with (Application) {
     CreateToolbar (sToolBarName);
     AddScriptToolbutton (sToolBarName, "C:\\temp\scripts\hello.js", "hello.js",'A', "");
     ShowToolBar(sToolBarName);
}
}

AddTagToolbutton

Syntax

AddTagToolbutton(wsToolbarName, wsTagStart, wsTagEnd, wsHint, wsCaption, wsImageFile: WideString): WordBool; 

Description

Boolean. Adds a tag toolbutton (inserts tag pair when clicked) to the passed toolbar. Fails if toolbar does not exist. Returns True if a toolbutton already exists, but does not add a duplicate button.

Example

function Main(){
  with (Application){
    AddTagToolButton('Common', TagCase('<blockquote>'), 
TagCase('</blockquote>'), 'Block quote', 'BQ', '');
  }
}

AddVTMToolbutton

Syntax

AddVTMToolbutton(wsToolbarName, wsScriptFile, wsHint, wsCaption, 
wsImageFile: WideString): WordBool; 

Description

Boolean. Adds a VTM toolbutton (displays passed VTM dialog box when clicked) to the passed toolbar. Fails if the toolbar does not exist. Returns True if a toolbutton already exists, but does not add a duplicate button.

Example

function Main(){
  var sVTM_File = 'C:\\Program Files\\Macromedia\\ColdFusion Studio 5\\Extensions\\TagDefs\\XHTML\\blockquote.vtm';

  with (Application){
    AddVTMToolbutton('Common', sVTM_File, 'Block quote', 'BQ', '');
  }
}

CreateToolbar

Syntax

CreateToolbar(wsToolbarName: WideString): WordBool; 

Description

Boolean. Creates a new, undocked toolbar of the passed name. Fails if the toolbar of the same name already exists.

Example

function Main() {
Var sToolBarName = "MyToolBar";

with (Application) {
     CreateToolbar (sToolBarName);
     ShowToolBar(sToolBarName); 
}
}

DeleteToolbar

Syntax

DeleteToolbar(wsToolbarName: WideString): WordBool; 

Description

Boolean. Physically deletes the toolbar. Fails if the toolbar does not exist or if the toolbar is one of the built-in toolbars. Works only on custom toolbars; built-in toolbars can be hidden, but not deleted.

Example

function Main() {
Var sToolBarName = "MyToolBar";

with (Application) {
     DeleteToolbar (sToolBarName);
} 
}

HideToolbar

Syntax

HideToolbar(wsToolbarName: WideString): WordBool; 

Description

Boolean. Hides a toolbar. Fails if the toolbar does not exist.

Example

function Main() {
Var sToolBarName = "MyToolBar";

with (Application) {
     HideToolbar (sToolBarName);
}
}

SetToolbarDockPos

Syntax

SetToolbarDockPos(wsToolbarName: WideString; nDockPos: Integer): Word-Bool; 

Description

Boolean. Sets the docking position of the toolbar. Fails if the toolbar does not exist.

The following values for nDockPos are allowed :

1 = Top
2 = Bottom
3 = Left
4 = Right

Example

function Main(){
  with (Application){
    SetToolbarDockPos('Standard', 2);
  }
}

ShowToolbar

Syntax

ShowToolbar(wsToolbarName: WideString): WordBool; 

Description

Boolean. Displays a toolbar if it is not already showing. Fails if the toolbar does not exist.

Example

function Main() {
Var sToolBarName = "MyToolBar";

with (Application) {
     CreateToolbar (sToolBarName);
     ShowToolBar(sToolBarName); 
}
}

ToolbarExists

Syntax

ToolbarExists(wsToolbarName: WideString): WordBool; 

Description

Boolean. Returns True if the passed toolbar exists.

Example

function Main() {
with (Application) {
  
sToolBarName = InputBox (VersionText, "Enter the Toolbar name.", "MyToolbar");
        
  while (ToolbarExists(sToolBarName) != 0){    
         sToolBarName = InputBox (VersionText, "Please choose 
            another name.", "MyToolbar");
  }
}  
}

Sample toolbar script 1

//******************************************************//
// This script creates a toolbar named Apps if one does not exist,
// then adds two custom toolbuttons to it. The first toolbutton
// launches Windows Explorer, the second one opens Windows Explorer
// at the current folder in the editor.
//****************************************************//
function Main() {      
  var TB_NAME = 'Apps';
  var app = Application;    

  if (!app.ToolbarExists(TB_NAME)) {
    app.CreateToolbar(TB_NAME);
  }
  app.AddAppToolbutton(TB_NAME, 'c:\\windows\\explorer.exe', ",
  'Explorer');
  app.AddAppToolbutton(TB_NAME, 'c:\\windows\\explorer.exe', 
    app.CurrentFolder, 'Explorer - Current Folder');    

Here's the same code in VBScript:

Sub Main
  const TB_NAME = "Apps"
  Dim app

  set app = Application
  if not app.ToolbarExists(TB_NAME) then
    app.CreateToolbar TB_NAME
  end if

  app.AddAppToolbutton TB_NAME, "c:\windows\explorer.exe", "",
    "Explorer"
  app.AddAppToolbutton TB_NAME, "c:\windows\explorer.exe",
    app.CurrentFolder, "Explorer - Current Folder"
End Sub

Sample toolbar script 2

//*************************************************************//
// This script creates a toolbar which is capable of executing 
// all of the scripts contained in the Document Cache
//*************************************************************//

function Main () {

var sToolBarName;
var Result; 
var count;
var fname;
var fnamepath;
  
  with (Application) {fnamepath
     sToolBarName = InputBox (VersionText, "Enter the Toolbar name.", "MyToolbar");
        
     while (ToolbarExists(sToolBarName) != 0){    
             sToolBarName = InputBox (VersionText, "Please chose another name.", "MyToolbar");
       }  
     
     CreateToolbar (sToolBarName);
     ShowToolBar(sToolBarName); 
     count = 0;
     
     while (count <= (DocumentCount-1)){
         
        fnamepath = DocumentCache(count).FileName
        fname = ExtractFileName(fnamepath);
        AddScriptToolbutton (sToolBarName, fnamepath, fname, count, "");
         count ++;
     
     }
  }
}

Comments