EViews COM Automation Server: Interface or COM?

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

maxchen
Posts: 191
Joined: Fri Oct 10, 2008 4:03 pm

EViews COM Automation Server: Interface or COM?

Postby maxchen » Wed Feb 09, 2011 7:43 pm

EV7.1, Matlab R2010b, on 32bit XP

EViews COM Automation Server and Matlab as client, try the following Matlab code

Code: Select all

hm = actxserver('Eviews.Manager'); ha = hm.GetApplication; h = actxGetRunningServer('Eviews.Application'); %ha : Interface.EViews_1.0_Type_Library.IApplication %h : COM.Eviews_Application
note that in Matlab, ha is Interface.EViews_1.0_Type_Library.IApplication, and h is COM.Eviews_Application

Code: Select all

ha.Run('wfcreate u 4') h.Run('wfcreate u 4')
both lines works.

I find that both h and ha have same methods, what are the differences then?

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: EViews COM Automation Server: Interface or COM?

Postby EViews Steve » Thu Feb 10, 2011 9:10 am

Great question...

The GetApplication method returns the EViews.IApplication interface, which is the one that we publish to everyone for general use.

Our EViews.Application class obviously supports this interface. However, it also supports another interface that is used between it and the calling Manager class in order to do some important security checks behind the scenes. We only allow use of our Application object after it has been enabled by the calling Manager class.

If you have multiple instances of EViews running at once, your code may not work depending on which instance is returned to you via GetApplication and which instance is returned to you via the GetRunningServer call. GetApplication uses our internal interface to enable the Application object using our security protocols. If your call to GetRunningServer returns you a different EViews instance, that application object will be unusable.

So the safest thing to do is to always use the instance returned by GetApplication.

Oh and FYI, you can pass a parameter to GetApplication to denote whether it should create a new instance of EViews or if it should try and get an instance that is already running.

Steve

maxchen
Posts: 191
Joined: Fri Oct 10, 2008 4:03 pm

Re: EViews COM Automation Server: Interface or COM?

Postby maxchen » Thu Feb 10, 2011 6:30 pm

thanks!
How to pass the parameter?

Code: Select all

>> app = hm.GetApplication('ExistingOrNew') ??? Error: Type mismatch, argument 1
seems Matlab R2010b not able to do this. In matlab's guide of apiext.pdf
Limitations to custom interface support are:
• Custom interfaces are not supported on a 64-bit version of MATLAB.
• You cannot invoke functions with optional parameters.

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: EViews COM Automation Server: Interface or COM?

Postby EViews Steve » Fri Feb 11, 2011 8:22 am

The first parameter to GetApplication is actually an enumerated integer type. You can find these values if you used some other programming language that allowed the use of COM objects, such as VBA, or any .NET language and it showed you a list of possible values for each parameter. But this type only has three possible values so I'll just tell you what they are:

Code: Select all

//CreateType Enumeration: NewInstance = 0 //always create a new instance of EViews ExistingOrNew = 1 //this is the default value -- if an instance of EViews already exists, connect to that one, otherwise create a new one ExistingOnly = 2 //only connect to an existing instance of EViews, otherwise return nothing
So just call it like this:

Code: Select all

>> app = hm.GetApplication(0)
Steve


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests