Integrating UE and Matlab

Help with setting up and configuring custom user tools in UltraEdit (based on command line input)

Integrating UE and Matlab

Postby UEMatlab » Mon Mar 30, 2009 5:30 am

I'd like to call Matlab from UE 14.20 using Matlab as an automation server, basically as in the example below. However I'm getting an error with the "new ActiveXObject" line.

Is it possible at all? If not any ideas how to do it?

Code: Select all
function callMatlab(sCommandStr) {
   var MatLab = new ActiveXObject("matlab.application");
   
   MatLab.Execute (sCommandStr)
   
}

var sCommandStr = ""

if (UltraEdit.document[1].isSel()){
   
   sCommandStr = UltraEdit.activeDocument.selection;
   callMatlab(sCommandStr);

}


Best Regards
Max
UEMatlab
Newbie
 
Posts: 2
Joined: Mon Mar 30, 2009 5:23 am

Re: Integrating UE and Matlab

Postby Mofi » Mon Mar 30, 2009 11:00 am

The script feature of UltraEdit uses the core engine of JavaScript. Creating an ActiveX object is not supported by the core engine of JavaScript. You need to write a Visual Basic script (*.vbs) which you can run from within UltraEdit via a user tool. I don't have MatLab nor any knowledge how to write Visual Basic scripts. So I can't help you further than that the command line for the user tool should be something like:

C:\Windows\System32\wscript.exe "name of your VB script with full path" "%sel%"

%sel% is replaced by UltraEdit on launch of the user tool with the selected text which of course can't be a multi-line string.

See also Invoke COM objects from a javascript?
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4049
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Integrating UE and Matlab

Postby UEMatlab » Tue Mar 31, 2009 3:27 am

Mofi,

Thanks for the answer and the link I didn't find that when searching the forum.

Actually I thought of using a user tool, using a temporary file for in- and output, however that's not so very elegant. Anyway that is apparently the way to do it as I will have multi-line statements to pass so the %sel% won't work.

For anyone interested I'll post my solution here, when/if I get it working.

Thnx again
-Max
UEMatlab
Newbie
 
Posts: 2
Joined: Mon Mar 30, 2009 5:23 am


Return to Custom User Tools/Tool Configuration