DLL + COM Objects

sorry for so many questions. I hope I can ask 1 more and then I probably know most about direct translations from AFL to a DLL

With respect to COM Objects the manual says: “The VAR_DISPATCH type is provided for calling COM objects and will not be covered here”

does this mean they can be called inside a DLL, but it is just not explained how?

If it is possible could I be shown how to translate the following AFL?

            AB = CreateObject( "Broker.Application" );
            AW = AB.ActiveWindow;
            AW.ZoomToRange( bv, ev );

where bv and ev are defined as (but I can translate this myself):
bv = DateTimeToStr( LastValue( ValueWhen( xx1, DateTime() ) ) );
ev = DateTimeToStr( LastValue( ValueWhen( xx2, DateTime() ) ) );

I started off with:

		AmiVar AB;
		arg1[0].type = VAR_STRING;
		arg1[0].string = (char *)gSite.Alloc(100);
		strcpy_s(arg1[0].string, 100, "Broker.Application");
		AB.type = VAR_DISP;
		AB = gSite.CallFunction("CreateObject", 1, arg1);

not sure if it is correct and I’m stuck here …

thanks, Ed

1 Like

Why would you want to do multiple indirection? Just invoke the COM Automation object from the plugin code directly. Use marshalling to coax parameters.

1 Like

And as I said many times: calling ZoomToRange from within AmiBroker is bad idea. OLE is meant to be called from OUTSIDE of AmiBroker (external script).

yes thanks, I know. Someone wanted a little zoom tool. I just left the OLE part in the AFL and call for the dates with functions. But I know it is not supposed to be used this way

I have the same question. You said that 'Just invoke the COM Automation object from the plugin code '...Can you please explain it? What is the code to write to invoke it? I am using c++.