win32ole: Pass by Reference

Z

zxem

All,

I am using Ruby 1.8.6 now and trying to so a pass by reference COM
call through win32ole.

The code looks like this: (I am not really calling Excel)

------------------------------------------------------
excel = WIN32OLE.new("excel")
excel.getCell(cell, column, row)
---------------------------------------------------

The first parameter I need to pass into getCell on line2 is a complex
object(not String/double).
Could anyone please teach me how to do this call in Ruby?

Cheers!
 
J

Jano Svitok

All,

I am using Ruby 1.8.6 now and trying to so a pass by reference COM
call through win32ole.

The code looks like this: (I am not really calling Excel)

------------------------------------------------------
excel = WIN32OLE.new("excel")
excel.getCell(cell, column, row)
---------------------------------------------------

The first parameter I need to pass into getCell on line2 is a complex
object(not String/double).
Could anyone please teach me how to do this call in Ruby?

Look at 1.9 WIN32OLE documentation. The last paragraph discusses the
returning by reference (in short, you'll find the result in
WIN32OLE::ARGV).

There are some interesting threads about this in the archive. Look for
Masaki Suketa's posts (he is the author/maintainer).
One of them is this:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/232146

Jano
 
Z

zxem

Look at 1.9 WIN32OLE documentation. The last paragraph discusses the
returning by reference (in short, you'll find the result in
WIN32OLE::ARGV).

There are some interesting threads about this in the archive. Look for
Masaki Suketa's posts (he is the author/maintainer).
One of them is this:http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/232146

Jano

Hi,

I went through all the existing threads before I posted this one
because I did not fully understand them. Could anyone give me some
more detailed examples.

Cheers!
 
J

Jano Svitok

Hi,

I went through all the existing threads before I posted this one
because I did not fully understand them. Could anyone give me some
more detailed examples.

Can you specify the problem in more detail? Is it that

(1) you need to pass an object to the method,
or
(2) the method returns the complex object, and you actually do not
need to pass it in,
or
(3) both?

If you can specify the exact API (if it is public) it would be easier
to help you.
So for now:

for (1) I think that's easy. WIN32OLE.new(type)

for (2): try passing 0 or nil as the parameter, and read the result
from WIN32OLE::ARGV.first
if 0/nil doesn't work then create an empty object and pass that. Try
inspecting ARGV to find out what stuff does it contain.

(I don't remember why but) in some cases I used
WIN32OLE#invoke(method, *args) to call the COM object.
 
Z

zxem

Can you specify the problem in more detail? Is it that

(1) you need to pass an object to the method,
or
(2) the method returns the complex object, and you actually do not
need to pass it in,
or
(3) both?

If you can specify the exact API (if it is public) it would be easier
to help you.
So for now:

for (1) I think that's easy. WIN32OLE.new(type)

for (2): try passing 0 or nil as the parameter, and read the result
from WIN32OLE::ARGV.first
if 0/nil doesn't work then create an empty object and pass that. Try
inspecting ARGV to find out what stuff does it contain.

(I don't remember why but) in some cases I used
WIN32OLE#invoke(method, *args) to call the COM object.

Great thanks for your help.

Option 2 solved my problem.

My sample code:
------------------

curve.getNonWingProperties(
0,
0,
0,
0,
0,
0,
0,
0);

tenor_date_out = WIN32OLE::ARGV[0];
domestic_currency_out = WIN32OLE::ARGV[1];
foreign_currency_out = WIN32OLE::ARGV[2];
is_face_domestic_out = WIN32OLE::ARGV[3];
is_booking_domestic_out = WIN32OLE::ARGV[4];
ATM_style_out = WIN32OLE::ARGV[5];
atTheMoneyVolatility_out = WIN32OLE::ARGV[6];
atTheMoneyVolIsMissing_out = WIN32OLE::ARGV[7];
puts tenor_date_out.GetSerialDouble;
 
Z

zxem

Can you specify the problem in more detail? Is it that
(1) you need to pass an object to the method,
or
(2) the method returns the complex object, and you actually do not
need to pass it in,
or
(3) both?
If you can specify the exact API (if it is public) it would be easier
to help you.
So for now:
for (1) I think that's easy. WIN32OLE.new(type)
for (2): try passing 0 or nil as the parameter, and read the result
from WIN32OLE::ARGV.first
if 0/nil doesn't work then create an empty object and pass that. Try
inspecting ARGV to find out what stuff does it contain.
(I don't remember why but) in some cases I used
WIN32OLE#invoke(method, *args) to call the COM object.

Great thanks for your help.

Option 2 solved my problem.

My sample code:
------------------

curve.getNonWingProperties(
0,
0,
0,
0,
0,
0,
0,
0);

tenor_date_out = WIN32OLE::ARGV[0];
domestic_currency_out = WIN32OLE::ARGV[1];
foreign_currency_out = WIN32OLE::ARGV[2];
is_face_domestic_out = WIN32OLE::ARGV[3];
is_booking_domestic_out = WIN32OLE::ARGV[4];
ATM_style_out = WIN32OLE::ARGV[5];
atTheMoneyVolatility_out = WIN32OLE::ARGV[6];
atTheMoneyVolIsMissing_out = WIN32OLE::ARGV[7];
puts tenor_date_out.GetSerialDouble;

Hi all,

I raised a bug related to win32ole.c weeks ago. Could anyone who is
interested in this topic take a look at this
http://rubyforge.org/tracker/index.php?func=detail&aid=15020&group_id=426&atid=1698?

Cheers!
Xin Zhao
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top