From: zxem Date: 2007-11-15T19:45:02+09:00 Subject: Re: win32ole: Pass by Reference On Nov 14, 5:56 pm, Jano Svitok wrote: > On Nov 14, 2007 6:05 PM, zxem wrote: > > > > > > On Nov 14, 2007 1:10 PM, zxem wrote: > > > > > 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? > > > 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. 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;