Script Editor

Use Script Editor to edit, compile and run scripts. Also it should be used to debug simple scripts or automate single use tasks, when you don't wish to make special menu item or toolbar button. In addition, you may explore DM2003 object model and inspect objects.

Script Editor window

Fig1. DM2003 Script Editor window looks like other modern IDEs.

How to use Script Editor?

At a glance, Script Editor window is a "mini-IDE" which has following main elements:

  1. Object Tree - selected object from the Object Tree may be inspected, that is, you may interactively change its properties and invoke its methods with the Dispatch dialog box (Script|Dispatch menu item). Script Editor object represents variables and functions from the script in the Editor (script need to be compiled).

  2. Editor - this is where you edit script code. Use items from the File, Search and Edit menus just like in any text editor. For your convenience, several frequently used commands have appropriate toolbar buttons. Editor implements syntax highlighting features, drag-n-drop editing and has a lot of special keyboard shortcuts.

    Before you will be able to run procedures, you must compile script from the editor (Script|Compile menu command). Also use Script menu to select script language if it is not detected automatically by the file extension (*.js for JScript, *.vbs for VBScript). You may use Action Wizard dialog box (Help|Wizards|Action Wizard) to add code for Scripter.dll Action object (see example for more details).

  3. Procedures drop-down list - click "Run" button (or appropriate menu item) to run selected procedure (only procedures w/o parameters are added to this list on compilation). In addition, you may use "Evaluate" command to inspect global variable or call function. Set timeout (Script|Timeout menu item) to limit total script execution time.

Debugging scripts

Although you can inspect variables and run code as well as get comprehensive compilation and runtime error diagnostics, Script Editor doesn't support full set of debugging features like breakpoints, step-by-step execution and so on. Instead, you can easily use powerful professional-quality script debuggers available from Microsoft (both free stand-alone Script Debugger utility and Script Editor integrated in the MSVS and Microsoft Office). Read documentation on these products how to attach debugger to the DM2003.EXE process and debug script blocks. There's a couple of hints:

It should be noticed that Script Editor and debuggers from MS have substantially different application scope, and in fact their functionality do not significantly overlap. You use Script Editor mainly to type texts, that's why it includes various productivity features such as Code Completion and a lot of wizards, while debuggers typically are not used for editing. In addition, scripting applications usually are very simple so that one rarely has to trace code execution under debugger.

Working with HTML

In many cases you may find convenient to use Script Editor for editing HTML code. Click File|New menu item, then select Empty HTML or HTML Applet Wizard to create new HTML document, or just open existing HTML file. Use File|Browse command to copy the contents of the editor directly into DM2003 Browser Window (this command doesn't work until Browser Window have loaded any HTML document, and some HTML features like cookies and linked files are not supported).

HTML Applet Wizard supports several type of application templates used by DM2003, including HTML-based applets and device drivers. Also you may use Measurement System Wizard to make ready-for-use DAQ applications.

Productivity features

Although the development of Script Editor was focused on characteristic features of Data Master 2003 software and does not duplicate existing development tools like MSE/MSVS, it includes several functions that help you write your script applications for DM2003. A set of wizards available in Help|Wizards menu assist you with creation of User Actions, event hanldlers, HTML code of ActiveX objects and application templates. Another cool features are Code Completion (you can activate it by pressing Ctrl+Space somewhere in the editor) and Auto Complete (invoked by Shift+Space).

Notice: these features now are in the beta phase, so they are more limited than IntellisenseTM features in Visual Studio. Keep in mind that script languages are typeless, and as a result, it is impossible to determine whether some variable is an object with a set of members or not. At the moment of writing Code Completion supports three modes: i) if it is invoked at some blank space, a list of constants from DM2003 TLB and dynamic set of specially declared variables is shown; ii) in the declaration clause (e.g. after dim keyword in VBScript) you can define variable type as a comment and iii) if invoked after some identifier, a list of members is displayed if the type of this identifier can be resolved. The list of members is created dynamically by TLB information, static table of identifiers (properties of DM2003 objects that return other objects) also is supported. Currently dynamic identifier table works only in VBScript mode (and in VBScript blocks in HTML files).

Screenshots below demonstrate how to use Code Completion and Auto Complete templates:

Auto Complete feature in DM2003 Script Editor

Fig2. Auto Complete feature in DM2003 Script Editor. You can change the set of available templates in the Editor Properties dialog box (View | Preferences menu item).
Code Completion - declare variable type
dim MyVar ' as IDMDocument2
Fig3. It is possible to assign a type (implemented interface) to a variable, for future use with another CC feature - member list (see below). Predefined identifiers from the static table also have a type. In the popup list you can see interfaces (object "types") from the DM2003 type library.

Code Completion - select object variable and its members

Fig4. Code Completion - select object variable (2) from the list of identifiers and constants and then select its members (3). Notice that the list (2) contains variables whose type was explicitly declared above, as well as some number of predefined (static) variables (e.g. Server). The list of members obtained from TLB.