How can I access the active document's index number? I can set the active document by using UltraEdit[x].setActive(); but how can I get the index of the currently active document?
Thanks.
Thanks.
Code: Select all
UltraEdit.activeDocument.write("Active document has index="+getActiveDocumentIndex());
/* Find the tab index of the active document */
function getActiveDocumentIndex() {
var tabindex = -1; /* start value */
for (var i = 0; i < UltraEdit.document.length; i++)
{
if (UltraEdit.activeDocument.path==UltraEdit.document[i].path) {
tabindex = i;
break;
}
}
return tabindex;
}
Edit 2010-03-02: In UE version 16.00 a new property was added to the scripting environment: var docIx = UltraEdit.activeDocumentIdx; (See more UE 16.00 scripting enhancements...).Jorrasdk wrote:Hi IDM Support
Feature request: UltraEdit.activeDocumentIdx
New scripting read only property which returns the tab index of the currently active file.
Should return -1 if there are no open files in the editor.
Up to now I have used a function shown below ( getActiveDocumentIndex() ) to find the index of the active document, but it is tedious to always have this function in my script (as we can't include other scripts yet .
I need UltraEdit.activeDocumentIdx to know which document to return to if I have performed some newFile's or setActive's on other files. It is also nice to create aliases to simplify code like this:
RegardsCode: Select all
var mySourceDoc = UltraEdit.document[UltraEdit.activeDocumentIdx]; UltraEdit.newfile(); var myNewWorkDoc = UltraEdit.document[UltraEdit.activeDocumentIdx]; mySourceDoc.selectLine(); myNewWorkDoc.write(mySourceDoc.selection);
jorrasdk