Prev | Next |
Script Editor
Using the Script Editor you can perform a number of operations on an open script file, such as:
- Save changes to the current script
- Save the current script under a different name
- Run the script
- Debug the script
- Stop the executing script
- View the script output in the 'Scripts' tab of the System Output window
The editor is based on, and provides the facilities of, the common Code Editor in the application work area.
Access
Ribbon |
Specialize > Tools > Script Library > expand script group and right-click on [script name] > Edit Script or Specialize > Tools > Script Library > expand script group and double-click on [script name] |
Facilities
Facility |
Detail |
See also |
---|---|---|
Scripting Objects |
Enterprise Architect adds to the available functionality and features of the editor script language by providing inbuilt objects; these are either Type Libraries providing Intelli-sense for editing purposes, or Runtime objects providing access to objects of the types described in the Type Libraries. The available Intelli-sense scripting objects are:
The runtime scripting objects are:
|
Enterprise Architect Object Model Session Object |
Script Editing Intelli-sense (Required Syntax) |
Intelli-sense is available not only in the 'Script Editor', but also in the 'Script Console'; Intelli-sense at its most basic is presented for the inbuilt functionality of the script engine. For Intelli-sense on the additional Enterprise Architect scripting objects (as listed) you must declare variables according to syntax that specifies a type; it is not necessary to use this syntax to execute a script properly, it is only present so that the correct Intelli-sense can be displayed for an item. The syntax can be seen in, for example: Dim e as EA.Element Then when you type, in this case, e., the editor displays a list of member functions and properties of e's type. You select one of these to complete the line of script; you might, therefore, type: VBTrace(e. As you type the period, the editor presents the appropriate list and you might double-click on, for example, Abstract; this is inserted in the line, and you continue to type or select the rest of the statement, in this case adding the end space and parenthesis: VBTrace(e.Abstract) |
|
Keystrokes |
In the Script Editor or Console, Intelli-sense is presented on these keystrokes.
|
|
Include Script Libraries |
An Include statement (!INC) allows a script to reference constants, functions and variables defined by another script accessible within the Scripting Window. Include statements are typically used at the beginning of a script. To include a script library, use this syntax: !INC [Script Group Name].[Script Name] For example: !INC Local Scripts.EAConstants-VBScript |
|
Using Inbuilt Math Functions |
Various mathematical functions are available within the Script Editor, through the use of the inbuilt Maths object. You can access the Maths object within the Script Editor by typing 'Maths' followed by a period. The Intelli-sense feature displays a list of the available mathematical functions provided by the Cephes Mathematical Library. For example: Session.Output "The square root of 9 is " & Maths.sqrt(9) Session.Output "2^10 = " & Maths.pow(2,10) The Maths object is available in the Unified and Ultimate Editions of Enterprise Architect. |
|
Using COM / ActiveX Objects |
VBScript, JScript and JavaScript can each create and work with ActiveX / COM objects. This can help you to work with external libraries, or to interact with other applications external to Enterprise Architect. For example, the Scripting.FileSystemObject Class can be used to read and write files on the local machine. The syntax for creating a new object varies slightly for each language, as illustrated by these examples: VBScript: set fsObject = CreateObject("Scripting.FileSystemObject") JScript: fsObject = new ActiveXObject("Scripting.FileSystemObject"); JavaScript: fsObject = new COMObject("Scripting.FileSystemObject"); |
|
Using JavaScript with Out-of-process COM Servers |
Users of JavaScript in Enterprise Architect can access out-of-process COM servers. The application must be registered on the machine as providing local server support. The syntax for creating or obtaining a reference to an out-of-process server is: var server = new COMObject(progID, true); where progID is the registered program ID for the COM component ('Excel.Application', for example). |
|
System Script Library |
When Enterprise Architect is installed on your system, it includes a default script library that provides a number of helpful scripting functions, varying from simple string functions to functions for defining your own CSV or XMI import and export. To use the script library you must enable it in the 'MDG Technologies' dialog ('Specialize > Technologies > Manage Technology' ribbon option). Scroll through the list of technologies, and select the 'Enabled' checkbox against 'EAScriptLib'. |
Notes
- The Script Editor is available in the Corporate, Unified and Ultimate Editions
- Enterprise Architect scripting supports declaring variables to match the Enterprise Architect types; this enables the editor to present Intelli-sense, but is not necessary for executing the script
Learn more
- Editing Source Code
- Scripting Window
- Script Debugging
- Cephes Mathematical Library (3rd-Party, Online Resource)