Forum: Ruby Win32OLE: how to pass parameters by reference?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jan S. (Guest)
on 2007-01-02 18:42
(Received via mailing list)
Hi,

I need to call an OLE method that takes a VARIANT argument, and fills
it with data. How can I accomplish this? Somewhere in the ruby-cvs
attic I've found WIN32OLE_VARIANT, unfortunately it is removed now.

Long obj.GetX(varX As Variant)

long is success/error, varX is the actual value for X.
invoke_kind of the method is FUNC.

Thanks
Masaki S. (Guest)
on 2007-01-04 00:08
(Received via mailing list)
In message "Win32OLE: how to pass parameters by reference?"
    on 07/01/03, "Jan S." <removed_email_address@domain.invalid> writes:

> I need to call an OLE method that takes a VARIANT argument, and fills
> it with data. How can I accomplish this? Somewhere in the ruby-cvs
> attic I've found WIN32OLE_VARIANT, unfortunately it is removed now.

No, WIN32OLE_VARIANT is Ruby 1.9 feature.
Sorry, Ruby 1.8 does not support WIN32OLE_VARIANT.

In Ruby 1.8, WIN32OLE#_invoke method may help you.

  oleobj._invoke(dispid, [value], [WIN32OLE::VARIANT::VT_VARIANT])

The dispid is the dispatch id of the OLE method to call.
The value is the data which you want to pass.

  Regards,
  Masaki S.
Jan S. (Guest)
on 2007-01-04 01:13
(Received via mailing list)
On 1/3/07, Masaki S. <removed_email_address@domain.invalid> wrote:
>
> In Ruby 1.8, WIN32OLE#_invoke method may help you.
>
>   oleobj._invoke(dispid, [value], [WIN32OLE::VARIANT::VT_VARIANT])
>
> The dispid is the dispatch id of the OLE method to call.
> The value is the data which you want to pass.
>
>   Regards,
>   Masaki S.

In the meantime I have found the answer in your older answers. Thank
you for all of them. The trick was to google for 'output' instead of
'reference' ;-)

In this case, using WIN32OLE::ARGS was enough to get what I need.

I have added a doc patch (7557) to ruby tracker to document that. (I
have copied pieces from your examples if you don't mind).

Thanks again.
Jano
Pit C. (Guest)
on 2007-01-06 20:18
(Received via mailing list)
Jan S. schrieb:
> In the meantime I have found the answer in your older answers. Thank
> you for all of them. The trick was to google for 'output' instead of
> 'reference' ;-)
>
> In this case, using WIN32OLE::ARGS was enough to get what I need.
>
> I have added a doc patch (7557) to ruby tracker to document that. (I
> have copied pieces from your examples if you don't mind).

Jan, this is great. Enhancing the existing documentation of a library
after having solved a problem. May others (me included) be inspired by
your example.

Regards,
Pit
This topic is locked and can not be replied to.