"Script Explorer" for HomeSite and CF Studio

Utility for script coders

Works with Allaire Corp's ColdFusion Studio or HomeSite, v4.0 and up

(c) 2000 by Nate Weiss (nate@nateweiss.com).  All rights reserved.

Visit www.nateweiss.com from time to time for updates, etc.

 

  1. What is it?
  2. Limitations
  3. Installation
  4. Using The Script Explorer
  5. Customizing

 

also:

- ScriptX Requirement

- Installing Manually

- Version History

 

 

What is it?

The Script Explorer was put together while I was working on a project that called for a large number of client-side JavaScript functions.  The files were in several separate files, and I found that I was constantly printing them out or switching back and forth between them to remind myself of the exact function names and arguments, etc. 

 

Note:  In this document, the term JavaScript refers to both JavaScript and JScript.  The term function refers to a JavaScript function, a VBScript Sub, or a VBScript Function (unless stated otherwise).

 

So I put together this little utility, which gives you a handy way to look at all the functions in all your open files (see screenshot below).  In addition to giving you this quick "jog your memory" listing, it also lets you "jump" quickly to a function, or insert a call to the function into your work.  It will also add a comment block to the top of your file to enumerate all the functions in the file, to make your files somewhat more "self-documenting".  At first, it worked only with .js files, but I expanded it to work with either JavaScript/JScript or VBScript, in straight HTML files, or code files like .cfm, .asp, etc. 

 

The Explorer was designed with client-side scripts in mind, but I imagine it will also be helpful for people working with server-side JavaScript (via Netscape Enterprise/iPlanet/LiveWire) or server-side JScript/VBScript (via Active Server Pages, etc). 

 

 

Limitations

This is a simple utility.  It's useful but not particularly ambitious.  For now, note that:

 

It's possible that I might expand/improve upon this thing in the future.  Feel free to send suggestions my way, although I may not respond. 

 

 

Installation

  1. Unzip the files into a folder called jsFnBrowser. This folder must be within a folder called scripts, directly off Studio/Homesite's program directory.  For instance, for a typical Studio installation, the files would need to be in C:\Program Files\Allaire\ColdFusion Studio 4.5\scripts\jsFnBrowser
  2. In Studio/HomeSite, open the Install.js file in the folder you just created. 
  3. Press Ctrl + Shift + Q to install a Toolbar button for the Script Explorer.
  4. If you're using Studio/HomeSite 4.5 or higher, you could also assign a keystroke to the jsFnBrowser.js file, using the Options | Customize menu command ("Script Shortcuts" tab).  I like to use the F5 key.

 

That's it!  Close the dialogs and the button should be available.  Test it out by clicking the new Toolbar button.  If you get an "Automation Server" error message, then see ScriptX Requirement, below.  If you get any kind of "file not found" message, then you probably didn't put the files in the right place (see step 1, above).

 

 

 

 

Using The Script Explorer

While you're working with files that contain JavaScript or VBScript functions, just click the toolbar button to bring up the Script Explorer. 

  1. All functions in the current file are listed.
  2. You can see the functions in other open files by using the drop-down list at the top.
  3. The functions are listed alphabetically by default; you can switch to a non-sorted view by using the radio buttons at bottom left.
  4. Double-clicking on a function is the same as hitting the "Go To" button (see below). 

 

 

 

Buttons:

Annotate - Inserts a comment block at the top of the selected document, enumerating all the functions in the file, with their line numbers and comments. 

 

  • The Annotation is added to the very top of the document when used for the first time on a particular document.  You can then move it down to another spot if you wish (via cut-and-paste, etc).  Subsequent uses of the Annotate button should update the annotation "in place", wherever you place it.
  • Any line that has "function" as its first word (not including whitespace) and which thereafter contains a set of parentheses is assumed to be a function declaration.  If you split your declarations across multiple lines, this utility will probably not "see" them correctly.
  • Note that the comment listed in the Annotation is the *first* line of //-style comment that is found on the line(s) directly before or after the function declaration itself (the line with the word "function" in it). 
  • If there are comments before and after the declaration, the line above is assumed to be the relevant comment.

Go To: Brings the editor to the selected function, and closes the dialog box.  You're ready to edit or take a look at the function.

Scroll To: Same as Go To, execpt the dialog stays open.  Useful for jogging your memory about how a function works.

Insert: Inserts the selected function name and arguments into the current document (that is, the document you were working on when you opened the dialog).

 

 

 

Customizing

The Script Explorer supports a little bit of customization:

·        Color Coding: By default, JavaScript functions are shown with black text on white, and VBScript functions are shown with navy text on light blue.  The file langs.css can be adjusted to use different colors for each, using standard CSS syntax. 

·        File Extensions:  The Script Explorer usually scans files for both JavaScript and VBScript functions.  For some files, though, it's obvious that there will never be both types of functions present.  For instance, .js files would presumably never contain a VBScript function declaration.  You can adjust the DONT_SCAN_FOR_JS_EXTS and DONT_SCAN_FOR_VB_EXTS values in the Preferences.js file to change which files do not get scanned for which script languages.  For instance, if you knew you were never going to have any VBScript functions in your straight HTML files, you could add "htm" and "html" to the list of extensions for which VBScript scanning should be skipped.

·        Double-Click Behavior: By default, when you double-click in the list of functions, you are brought to that spot in the file (as if you had clicked the "Go To" button).  If you wish, you can change this behavior so that double-clicking inserts the current function, or merely scrolls to it.  To change the behavior, change the ON_DOUBLE_CLICK value in the Preferences.js file.  Allowable values are "Insert", "Go To", or "Scroll To" (case-sensitive).

 

 

 

ScriptX Requirement

The Script Explorer requires that the ScriptX runtime files be installed on your system.  Depending on the version of CF Studio or HomeSite you're using, this may or may not be the case already.

Studio/HomeSite

What you need to do

4.0

You will need to download and install ScriptX.

4.01

You should be all set.

4.5

  • If you upgraded to 4.5 from 4.01, you should be all set.

 

  • If you went straight from 4.0 (or earlier) to 4.5, or if you installed 4.5 "clean", then ScriptX is on your system, but may not have been registered.  This script will attempt to auto-register it, but may not be able to, depending on whether you have version 5.0 or later of the Windows Scripting engine on your system. 

    If, when you try to use this Script Explorer, you get an error like "Automation server can't create object", then open up a MS-DOS prompt, use
    CD to get to the Windows/System folder (on 95/98) or Winnt/System32 folder (on NT/2000).  Now type regsvr32 MCScripX.dll and hit Enter.  If you get a "registered successfully" message, you should be all set.  If not, download and install ScriptX.

4.51

You should be all set.

 

 

 

Installing Manually

You can also install the Script Explorer "manually", if you don't want to use the Install.js script or if it doesn't work for some reason.

 

  1. Go to the "Script" toolbar (or whatever toolbar you want), right-click on it, and choose Customize.
  2. Click "Add Custom Button".
  3. Select the "Execute an ActiveScript file" radio button

o       For "Script File":    specify jsFnBrowser.js

o       For "Button Image":   specify jsFnBrowser.bmp

o       For "Button Caption": leave blank

o       For "Button Hint":    type "Script Explorer"

 

     

 

 

Version History

2/10/99: Initial Release

2/17/99: Added support for VBScript, Preferences.js, langs.css.