No neither scripts nor macros have commands to invoke UC directly. Your idea with UltraEdit.runTool() seems to be the only solution. Parameters can't be passed directly as you point out.
But here is a script that are able to pass on two filenames as well as your preferred command line switches for UC Pro.
The trick is to construct a complete line with parameters for UC in a new file and select it. Selected text can be passed on to a tool using %sel%
I write futher comments in the script itself. I hope it works for you. (I have not UC installed myself but have tested against Beyond Compare which have a command line syntax that somewhat resembles UC).
- Code: Select all
// Create two file paths from current file and
// invoke UC using a tool and dynamic parameter %sel%
// Define the folders where files to be compare reside:
var path1 = "fpga\\mod_1\\rtl\\";
var path2 = "asic\\mod_1\\rtl\\"
// Define preferred UC command line switches:
var cmdSw = "-t -i";
// Get current file and path
var currentFilepath = UltraEdit.activeDocument.path;
// Get file index so we can restore the active tab
var restoreFileIx = getActiveDocumentIndex();
// Simple extraction of filename (assume windows path):
var fileName = currentFilepath.substr(currentFilepath.lastIndexOf("\\") + 1);
// Now open a new temp file and write UC command line input for %sel%
UltraEdit.newFile();
// Write command line switches:
UltraEdit.activeDocument.write(cmdSw);
// Write first file in quotes
UltraEdit.activeDocument.write(" \""+path1+fileName+"\"");
// Write second file in quotes
UltraEdit.activeDocument.write(" \""+path2+fileName+"\"");
// Now select the whole line to make it available for %sel%
UltraEdit.activeDocument.gotoLineSelect(1,1);
// Then run the tool invoking UC
// The command line of the tool should look something like:
// start uc %sel%
// Configure as DOS command because we use "start" so we will not wait for UC.
// UC must be in the DOS PATH
// Uncheck options: Save active file, capture output.
UltraEdit.runTool("UC");
// Close the temp file without saving
UltraEdit.closeFile(UltraEdit.activeDocument.path,2);
// Restore original file as active
UltraEdit.document[restoreFileIx].setActive();
// Helper function to find the tab index of the active document
function getActiveDocumentIndex() {
var tabindex = -1; /* start value */
for (i = 0; i < UltraEdit.document.length; i++)
{
if (UltraEdit.activeDocument.path==UltraEdit.document[i].path) {
tabindex = i;
break;
}
}
return tabindex;
}