IDM PowerTips

UltraEdit v16.00 Scripting Enhancements

One of UltraEdit’s trademark features is the ability to automate tasks through scripting. V16.00 extends the power of scripting further with includes, active document index, and more!

If you are not yet familiar with the scripting functionality in UltraEdit/UEStudio, please click here to view the Introduction to Scripting Power Tip.

Include a script file in another script

The “include” feature allows you to include/import a script file into another script. The “include” is listed in a line comment as follows.

If both scripts are in the same directory, you can include the script as such:

// include outputWindow1.js

If the scripts are in different directories, you can point to the fully qualified path:

// include C:\Users\TestUser\Documents\UEScripts\MyFunctions.js

Active Document Index property

If you have multiple files open in the editor, and you need to know which document is active (as it pertains to the document array), you can now retrieve the “index” number of the active file with the Active Document Index property.

var adI = UltraEdit.activeDocumentIdx;

Delete hidden/folded lines

Use the Delete Hidden Lines function to delete blocks of text, code, or data that are hidden.

UltraEdit.activeDocument.delAllHiddenLines();

Comment/Uncomment selection

Use the comment/uncomment selection commands to dynamically block comment (or uncomment) sections of code.

Note: You are not required to define your block comment characters. The block comment characters are dynamically retrieved – based on the file type – from the wordfile for the given language.

Comment (add)

UltraEdit.activeDocument.commentSelectionAdd();

Uncomment (remove)

UltraEdit.activeDocument.commentSelectionRemove();

Get file (document) line terminator type

The line terminator property is a document object command that allows you to read/retrieve the line terminator type for the specified file.

var lt = UltraEdit.activeDocument.lineTerminator;

Get/Set file (document) code page
The code page property is a document object command that allows you to set or read the code page for the specified file.

Read the code page for the active document.

var cp = UltraEdit.activeDocument.codePage;

Set the code page for the active document.

UltraEdit.activeDocument.codePage = 949;

Get file (document) encoding
The encoding property is a document object command that allows you to read/retrieve the encoding for the specified file.

var enc = UltraEdit.activeDocument.encoding;

Find/Replace in Files encoding properties

When searching/replacing text across multiple files, it may be necessary to specificy a file encoding type. To this end, the frInFiles command now supports useEncoding and encoding.

UltraEdit.frInFiles.useEncoding = true
; UltraEdit.frInFiles.encoding = 1252;