You can script the Application object's child objects to perform common tasks and to create toolbars dynamically.
ActiveDocument: object (read-only)
The active document. For details, see "ActiveDocument Object".
ApplicationType: integer (read-only)
//**********************************//
// 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: OleString (read-only)
Path to application executable.
function Main() { var sPath; with (Application) { sPath = AppPath; // Store the path in a variable } }
CurrentFolder: OleString
Path currently displayed in the local file list.
function Main(){ with (Application){ CurrentFolder = 'C:\\InetPub\\wwwroot'; } }
CurrentView: ITCurrentViewType
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.
function Main() { with (Application){ CurrentView = 2; // Set the view to Browse } }
//**********************************************************//
// 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: array of objects (read-only)
For details, see "DocumentCache Object" .
function Main(){ with (Application){ // Save the first document if (DocumentCache(0).Modified){ DocumentIndex = 0; ActiveDocument.Save(); } } }
DocumentCount: integer (read-only)
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: Integer
Tab index of current document.
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: OleString (read-only)
File name of application executable, including path.
function Main() { Var sExeName; with (Application){ sExeName = ExeName; // Store the path in a variable } }
Height: integer
Height in pixels of main window.
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: integer (read-only)
Instance handle of the application.
hWnd: integer (read-only)
IsColdFusionStudio: WordBool (read-only)
Boolean. Returns True
if the application is ColdFusion Studio or JRun Studio, False
if HomeSite.
function Main(){ with (Application){ if (IsColdFusionStudio){ // Show CF Advanced toolbar ShowToolBar('CFML Advanced'); } } }
Left: integer
Left (x-coordinate) of main window.
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: WordBool
Boolean. Specifies whether the resource tab displays.
function Main(){ with (Application){ // Toggle resource tab on/off ResourceTabShowing = !ResourceTabShowing; } }
ResultsShowing: WordBool
Boolean. Specifies whether the results tab displays.
function Main() { with (Application){ If (ResultShowing) ResultShowing = false; //If the result bar is showing - hide it Else ResultShowing = true; //Hide it otherwise } }
Top: integer
Top (y-coordinate) of main window.
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: OleString (read-only)
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: integer
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: integer
The following values are allowed:
0 - Normal
1 - Minimized 2 - Maximized
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; } }
BringToFront();
Brings the main window to the front of other applications.
function Main() { with (Application){ BringToFront(); } }
BrowseText(sText, BaseHREF: OleVariant);
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.
function Main() { Var sMessage; sMessage = "You are viewing this text in the browse mode of your "; sMessage = sMessage + VersionText; with (Application){ BrowseText (sMessage); } }
CloseAll(wbPromptToSave: WordBool): WordBool;
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
.
function Main() { with (Application){ CloseAll(); } }
ExecCommand(nCmdID: integer, nOptions: integer);
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
.
function Main() { with (Application){ ExecCommand(3); // Executes an Open File command. } }
ExtractFileName(const wsFile: WideString): WideString;
Returns only the file portion of the passed file name.
function Main() { Var sFullFilePath; Var sFileName; sFullFilePath = "C:/Temp/MyScript.js" with (Application){ sFileName = ExtractFileName(sFullFilePath); // Returns 'MySript.js' } }
ExtractFilePath(const wsFile: WideString): WideString;
Returns the path of the passed file (includes trailing '\').
function Main() { Var sFilePath; Var sFullFilePath; sFullFilePath = "C:/Temp/MyScript.js" with (Application){ sFilePath = ExtractFilePath(sFullFilePath); // Returns 'C:/Temp/' } }
GetApplicationSetting(nSettingID: Integer);
Retrieves a specific application setting based on a SettingID.
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(const wsImageName: WideString): Integer;
Returns the height in pixels of the passed image. Returns 0
on error.
/* 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(const wsImageFile: WideString; var nHeight, nWidth: Integer): WordBool;
Boolean. Retrieves the size of the passed image. Returns False
on error.
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(const wsImageName: WideString):Integer;
Returns the width in pixels of the passed image. Returns 0
on error.
See the GetImageHeight
example.
GetMemoryStatus(iMemType);
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(const wsBaseURL, wsFolderURL: WideString): WideString;
Returns the relative path of a folder given a base URL. For example,
GetRelativePath ("http://www.macromedia.com/", "http://www.macromedia.com/software/")
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(const wsFile: WideString): Integer;
Returns the index in the document tab of the passed file. Returns -1
If the file is not open.
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(const wsURL: WideString): WideString;
Retrieves a URL and returns its contents.
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(const wsURL: WideString): WideString;
Retrieves a URL and returns its contents.
/* 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(const wsURL: WideString; var vResponse: OleVariant): Integer;
Returns the HTTP status code for the passed URL. The text of the server response is returned in the second parameter.
GetURLStatusCode(const wsURL: WideString): Integer;
Returns the status code for the passed URL.
See the GetURLResponse
example.
HideProgress();
function Main() { with (Application){ HideProgress(); // Hides the progress bar } }
HTMLConvertTagCase(const wsHTML: WideString; const wbUpperCase: WordBool): WideString;
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.
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(const wsInTag, wsAttr: WideString): WideString;
Returns the value for a particular attribute of a tag. For example,
HTMLGetAttribute("<TABLE WIDTH=100>", "WIDTH");
function Main(){ var sWidth; with (Application){ // Get width attribute of a table tag sWidth = HTMLGetAttribute("<table width=100>", "width"); } }
HTMLGetTitle(const wsFile: WideString): WideString;
Returns the contents of an HTML file's title
tag. This only operates on local files.
function Main() { Var sFile; Var sTitle; sFile = "C:\\Temp\index.html"; with (Application) { sTitle = HTMLGetTitle (sFile); // Store the contents inside <INDEX> in sTitle } }
InputBox(const wsCaption, wsPrompt, wsDefault: WideString): WideString;
Displays a dialog box for obtaining user input.
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(sFile: OleVariant): WordBool;
Boolean. Returns True
if the passed file is open in the Document tab.
function Main(){ sFile = 'D:\\Test\\index.html'; with (Application){ if (!IsFileOpen(sFile)){ OpenFile(sFile); } } }
IsFileModified(sFile: OleVariant): WordBool;
Boolean. Returns True
if the passed file is open in the Document tab and was modified.
function Main(){ with (Application){ // Save current file if it is modified if (IsFileModified(ActiveDocument.FileName)){ ActiveDocument.Save(); } } }
InstallParserScript(const wsScriptFile, wsFileExtAssoc: WideString): WordBool;
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.
function Main(){ with (Application){ InstallParserScript('D:\\Download\\XHTML_2.scc', 'xhtml'); } }
LogMemoryStatus(const wsLogFile, wsDescrip: WideString);
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
.
function Main(){ with (Application){ LogMemoryStatus('D:\\Test\\MemLog.txt', 'Application Start'); } }
MessageBox(const wsText, wsCaption: WideString, nType: Integer): Integer;
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
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(wbUseDefaultTemplate: WordBool);
Boolean. Creates a new document, optionally from the default template.
function Main(){ with (Application){ NewDocument(true); } }
OpenFile(const wsFile: WideString): WordBool;
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.
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();
Moves to the next document in the Document tab. If the last document is showing, wraps to the first.
function Main() { Var sMessage; sMessage = "Hello world!"; with (Application) { NewDocument(false); NextDoc(); ActiveDocument.InsertText(sMessage); // Moving to the newly-created document } }
PreviousDoc();
Moves to the previous document in the Document tab. If the first document is showing, wraps to the last.
function Main(){ with (Application){ // Create a new blank document NewDocument(false); // Move back to previous file PreviousDoc(); } }
Quit();
This method attempts to exit from or quit the program. It prompts the user to save any unsaved documents prior to quitting.
function Main(){ var MB_YESNO = 4; var IDYES = 6; with (Application){ if (MessageBox('Exit HomeSite?', 'Confirmation Message', MB_YESNO) == 6){ Quit(); } } }
RunCodeSweeper();
Runs the CodeSweeper on the active document using the active CodeSweeper. To change the active CodeSweeper, use SetActiveCodeSweeper
.
function Main() { with (Application) { RunCodeSweeper (); } }
SaveAll(): WordBool;
Boolean. Saves all open documents. Returns True
if successful.
function Main() { with (Application) { SaveAll (); } }
SaveResultsToFile(const wsFile): WideString;
Saves the contents of the active Results window to the named file.
function Main() { with (Application) { SaveResultsToFile(); } }
SendToBack();
Sends the main window to the back of other applications.
function Main() { with (Application) { SendToBack (); } }
SetActiveCodeSweeper(const wsFileName: WideString): WordBool;
Changes the active CodeSweeper format file.
function Main(){ var sCS_File = 'C:\\Program Files\\Macromedia\\ColdFusion Studio 5\\Extensions\\CodeSweepers\\WebXML.vtm'; with (Application){ SetActiveCodeSweeper(sCS_File); } }
SetActiveResults(resType: TCurrentResultsType);
Boolean. Sets the active page in the Results tab.
The following values are allowed:
resSearch
resValidator resLinks resThumbnails
function Main() { with (Application) { SetActiveResults (); } }
SetApplicationSetting(nSettingID: Integer ovSettingVal: OleVariant);
Sets a specific application setting based on its SettingID.
function Main(){ var SET_EDITOR_FONTNAME = 300; with (Application){ SetApplicationSetting(SET_EDITOR_FONTNAME, 'Lucida Console'); } }
SetFileTabFolder(iTab: integer; sFolder: string);
Sets the active folder for each of the Files tabs.
function Main(){ var sFolder1 = 'C:\\Program Files\\Bradbury\TopStyle2'; var sFolder2 = 'C:\\InetPub\\wwwroot'; with (Application) { SetFileTabFolder(1, sFolder1); SetFileTabFolder(2, sFolder2); } }
SetProgress(nProgress: Integer);
Sets the position of the progress bar in the status area.
The following values are allowed:
1-100.
function Main() { with (Application) { SetProgress (15); } }
SetStatusText(sMessage: OleString);
Sets the text that displays in the status area.
function Main() { with (Application) { SetStatusText("Progress Indicator: "); } }
ShellToApp(const wsAppFileName: WideString): WordBool;
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(const wsAppFileName: WideString);
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.
function Main(){ with (Application){ // Edit current document in notepad and then reload it ShellToAppAndWait('notepad.exe ' + ActiveDocument.Filename); ActiveDocument.Reload(false); } }
ShowProgress();
function Main() { with (Application) { ShowProgress(); } }
ShowThumbnails(sFolder: OleString);
Shows thumbnails for all images in the passed folder.
function Main(){ with (Application){ ShowThumbnails(CurrentFolder); } }
StatusError(const wsMsg: WideString);
Displays an error message in the status bar. Message appears on a red background and displays for at least 5 seconds.
function Main(){ with (Application){ if (ActiveDocument.Modified){ StatusError('Current document is modified'); } } }
StatusWarning(const wsMsg: WideString);
Displays a warning message in the status bar. Message appears on a blue background and displays for at least 5 seconds.
function Main(){ with (Application){ if (ActiveDocument.ReadOnly){ StatusWarning('Current document is read-only'); } } }
TagCase(const wsTag: WideString): WideString;
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.
function Main(){ with (Application){ ActiveDocument.InsertText(TagCase('<a href="http://www.macromedia.com"'), false); } }
ToolbarDir: WideString (read-only);
Returns the path where toolbar files are located.
function Main(){ with (Application){ CurrentFolder = ToolbarDir; } }
Wait(nMilliseconds: Integer);
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.
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
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(wsToolbarName, wsExeFile, wsCmdLine, wsHint: Wide-String): WordBool;
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.
function Main(){ with (Application){ AddAppToolbutton('Standard', 'Notepad.exe', '', 'NotePad'); } }
AddScriptToolbutton(wsToolbarName, wsScriptFile, wsHint, wsCaption, wsImageFile: WideString): WordBool;
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.
function Main() { Var sToolBarName = "MyToolBar"; with (Application) { CreateToolbar (sToolBarName); AddScriptToolbutton (sToolBarName, "C:\\temp\scripts\hello.js", "hello.js",'A', ""); ShowToolBar(sToolBarName); } }
AddTagToolbutton(wsToolbarName, wsTagStart, wsTagEnd, wsHint, wsCaption, wsImageFile: WideString): WordBool;
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.
function Main(){ with (Application){ AddTagToolButton('Common', TagCase('<blockquote>'), TagCase('</blockquote>'), 'Block quote', 'BQ', ''); } }
AddVTMToolbutton(wsToolbarName, wsScriptFile, wsHint, wsCaption, wsImageFile: WideString): WordBool;
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.
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(wsToolbarName: WideString): WordBool;
Boolean. Creates a new, undocked toolbar of the passed name. Fails if the toolbar of the same name already exists.
function Main() { Var sToolBarName = "MyToolBar"; with (Application) { CreateToolbar (sToolBarName); ShowToolBar(sToolBarName); } }
DeleteToolbar(wsToolbarName: WideString): WordBool;
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.
function Main() { Var sToolBarName = "MyToolBar"; with (Application) { DeleteToolbar (sToolBarName); } }
HideToolbar(wsToolbarName: WideString): WordBool;
Boolean. Hides a toolbar. Fails if the toolbar does not exist.
function Main() { Var sToolBarName = "MyToolBar"; with (Application) { HideToolbar (sToolBarName); } }
SetToolbarDockPos(wsToolbarName: WideString; nDockPos: Integer): Word-Bool;
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
function Main(){ with (Application){ SetToolbarDockPos('Standard', 2); } }
ShowToolbar(wsToolbarName: WideString): WordBool;
Boolean. Displays a toolbar if it is not already showing. Fails if the toolbar does not exist.
function Main() { Var sToolBarName = "MyToolBar"; with (Application) { CreateToolbar (sToolBarName); ShowToolBar(sToolBarName); } }
ToolbarExists(wsToolbarName: WideString): WordBool;
Boolean. Returns True
if the passed toolbar exists.
function Main() { with (Application) { sToolBarName = InputBox (VersionText, "Enter the Toolbar name.", "MyToolbar"); while (ToolbarExists(sToolBarName) != 0){ sToolBarName = InputBox (VersionText, "Please choose another name.", "MyToolbar"); } } }
//******************************************************// // 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
//*************************************************************//
// 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 ++; } } }