Re: About Jacob and Jawin...

Morten Andersen <[email protected]>
Newsgroups gmane.comp.windows.devel.jawin
Organization Arosii Information Systems A/S
Message-ID <[email protected]>
Hi Santini

I am sending this mail to the mailing list too, so that it gets
archived. Please see my answer at the bottom of your mail:

Santini Alberto wrote:

> Sorry to write directly, but I have some problem with the mailing list.
> I registered, confirmed the email address, but the interface are saying me
> my email address is not authorized.
>
> With Jacob library I access to a COM object (StatConnectorSrv.StatConnector).
> I invoke some method and it returns a variant object (vector, matric, etc). It runs fine.
>
>     ActiveXComponent obj = new ActiveXComponent("StatConnectorSrv.StatConnector");
>     Dispatch d = (Dispatch) obj.getObject();
>     Variant v = Dispatch.call(d, "Init", "R");
>
>     v = Dispatch.call(d, "Evaluate", "x = 1:10");
>     SafeArray a = v.toSafeArray();
>     for (int i = a.getLBound(1); i <= a.getUBound(1); i++)
>               System.err.println(i + ") " + a.getInt(i));
>
>     v = Dispatch.call(d, "Evaluate", "matrix(7,3,3)");
>     a = v.toSafeArray();
>     System.out.println(a.getNumDim());
>     for (int i = a.getLBound(); i <= a.getUBound(); i++) {
>       for (int j = a.getLBound(); j <= a.getUBound(); j++) {
>         System.err.println(i + " " + j + " " + a.getDouble(i, j));
>       }
>     }
>
>
> Now I use Jawin
>
>     DispatchPtr app = new DispatchPtr("StatConnectorSrv.StatConnector");
>
>     app.invoke("Init", "R");
>     Object o = app.invoke("Evaluate", "matrix(7,3,3)");
>     app.invoke("Close");
>
> But I don't know how retrieve the values of my matrix in the Object o.
> I tried to cast the result of the invoke to Variant, but it fires a ClassCastException.
>
> Thanks in advance,
> Alberto Santini

First, I assume your are either using a version of Jawin recently
checked out of CVS or the release Roger and I made yesterday?

And then to your problem: At present, I don't think we support
SafeArrays 100% (which it looks like your method is returning, judging
from your Jacob-code-snip). I have implemented this locally (but it
still need some testing), but unfortunately, I have changed some of the
Jawin-interfaces, so my changes should probably not be checked into the
stable Jawin-CVS-branch (which is CVS-HEAD pt.).

Yesterday I started a quick discuss on the mailing list of whether we
should make a dedicated branch for the stable Jawin 1.x, and then be
able to "break" things in the unstable HEAD. But I don't think this will
happen immediately, as the different developers have to find time for it
(and typically Jawin development "jumps in and out of hibernate" :-)
when people find time for it).

So for now I suggest you stay with Jacob if it fulfills your
requirements? Perhaps Roger is able to supply some additional
information about your specific scenario with SafeArrays.

Oh, and by the way, you can do a:
        Object o = app.invoke("Evaluate", "matrix(7,3,3)");
        System.out.println(o.getClass().getName());

If you want to find out exactly what kind of object have been returned
to you.

Hope this helps you a little bit
Best Regards
Morten
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.