| Home » Products » UltraEdit/UEStudio » Getting Started | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Scripting commands |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Article Number: 1245 | Last Updated: Mon, Oct 24, 2011 12:05 PM
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Scripting in UltraEdit/UEStudio is enabled through embedding of the JavaScript engine. This allows users to enjoy the power and flexibility of the full JavaScript language while using the commands specified below to specifically interact with the editor (Application Object commands) or documents open in the editor (Document Object commands). Scripts may be edited in UltraEdit/UEStudio with integrated syntax highlighting for JavaScript in the default wordfile:
The scripting engine supports the core functionality of JavaScript 1.7. Further information on JavaScript may be found on the associated Mozilla site (http://developer.mozilla.org/en/docs/JavaScript).
For example, this script will generate a sequence of numbers and write them to the active document:
function recall(num) { UltraEdit.activeDocument.write(num + " "); } function num() { var i = 0, j = 1, n = 0; while (n < 10) { recall(i); var t = i; i = j; j += t; n++; } } num();
Further demo scripts may be found in the installation directory in the "scripts" subdirectory. For a short scripting tutorial please click here.
Including scripts in scripts If desired, users may include an external script in a script by reference as shown below:
// include externalScript.js
or
// include C:full path o externalscriptexternalScript.js
The include command must be preceded by a line comment. If a users wishes to exclude the included script for debugging purposes, the include should be preceded by a doubled line comment, i.e.:
// // include externalScript.js
Please note that scripts are executed as soon as the inclusion is processed, but inclusions are processed prior to the active script. If an include is inserted into the middle of a script file, it will actually execute prior to the script it is included in. Where users desire to build complex scripts in a modular fashion from smaller scripts, the best practice would be to create a master script file that calls the included scripts, i.e.:
// include script1.js // include script2.js // include script3.js
var_dump This function is included outside the other objects defined for scripting in UltraEdit. It displays structured information about the referenced information including type and value. Arrays and objects are explored recursively with values indented to show structure.
Example: var_dump(UltraEdit.frInFiles);
Default Variable Values UltraEdit supports several variable values that are initialized by default every time a script starts in UltraEdit:
Column Mode is always off. Hex Mode is always off. Insert Mode is always on. The regular expression engine is always set to Perl.
These items are set every time a script runs.
Application Object commands UltraEdit is the application object that all UltraEdit operations will be based on. The following commands act on the editor itself rather than the active document. Unless other parameters are noted, all Application Object commands must be invoked using the following format: UltraEdit.commandName();
The table below shows the Application Object commands:
Document Object commands document is a JavaScript array object which is a property of the UltraEdit application object. This is an array of all currently opened documents. The activeDocument parameter may be used to specify that output should be written to the active file or users may specify a file's index based on file tab order (i.e. document[0], ... document[8]). For example:
UltraEdit.activeDocument.write("test");
would write the word "test" to the active file, while the following:
UltraEdit.document[4].write("test");
would allow the user to have multiple files open and write the specified text to the fifth file (based on file tab order) currently open for editing.
Scripts may be commented for testing or documentation using "//".
Once a script has been created, it may be edited. Please note, that "^c" and "^s" may be used with many script commands and will be replaced with the contents of the clipboard (^c) and the text currently selected (^s) when used. This allows users to create a script that may reference a specific string and replace this with one of these two items to allow the string to be dynamically "specified" as the script is run. The following commands act on a document currently open for editing. Unless other parameters are noted, all Document Object commands must be invoked using the following format: UltraEdit.activeDocument.commandName();
The table below shows the Document Object commands:
Output Window Object commands outputWindow is a JavaScript array object which is a property of the UltraEdit application object. Unless other parameters are noted, all Output Window Object commands must be invoked using the following format: UltraEdit.outputWindow.commandName();
The table below shows the Output Window Object commands:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Attachments
There are no attachments for this article.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Related Articles
Inserting Special Characters
Viewed 1021 times since Thu, Oct 13, 2011
Large File Handling
Viewed 1327 times since Thu, Oct 20, 2011
Command Line Parameters
Viewed 6113 times since Thu, Oct 13, 2011
Insert/Overstrike Modes
Viewed 1047 times since Thu, Oct 13, 2011
ClassViewer
Viewed 1076 times since Thu, Oct 13, 2011
Scripting Demo and Tutorial
Viewed 1170 times since Thu, Oct 13, 2011
Cursor Arrows (Cursor Movement)
Viewed 998 times since Thu, Oct 13, 2011
Debugging PHP Scripts
Viewed 1210 times since Thu, Oct 13, 2011
Selecting Text
Viewed 874 times since Thu, Oct 20, 2011
Tab Indentation
Viewed 904 times since Thu, Oct 13, 2011
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|

English