[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Win32OLE output parameter access??

Dennis Misener

3/29/2006 1:23:00 AM

I am trying to use Ruby's WIN32OLE support to drive Mindjet's
Mindmanager.

Their Object Model reference shows the following method:

*** GetOffset Method ***

Returns the topic's position-offset relative to its parent.

expression.GetOffset(pxOffset, pyOffset)

expression Required. An expression that returns a Topic object.
pxOffset Required float *.
pyOffset Required float *.

My problem is how to the two floating point output values. See sample
below... Any help would be certainly appreciated. Thanks

---
require 'win32ole'

MAX_DEPTH=5

MM=WIN32OLE.new("Mindmanager.Application")
MM.visible=true

def randomMap node,label='Main',depth=5
node.text=label
depth.times do |index|
subnode=node.addSubtopic 'label'
subnode.invoke('getOffset',0.0,0.0) # How to get this to work???
p [:offset,WIN32OLE::ARGV] # Seems to echo parameters
randomMap subnode,'%s %02d' % [label,index+1],rand(depth)
end
end

node=MM.activeDocument.centralTopic
randomMap node

---

Generates the following error:

[:offset, [0.0, 0.0]] << mirrors the supplied inputs
G:/work/mindmanager/demo.rb:13:in `invoke': getOffset
(WIN32OLERuntimeError)
OLE error code:80040200 in MindManager.Application.6
Error: 'this topic is not able to execute the call'
HRESULT error code:0x80020009
Exception occurred.from C:demo.rb:13:in `randomMap'
from G:/work/mindmanager/demo.rb:11:in `times'
from G:/work/mindmanager/demo.rb:11:in `randomMap'
from G:/work/mindmanager/demo.rb:15:in `randomMap'
from G:/work/mindmanager/demo.rb:11:in `times'
from G:/work/mindmanager/demo.rb:11:in `randomMap'
from G:/work/mindmanager/demo.rb:20

5 Answers

Dave Burt

3/29/2006 6:57:00 AM

0

Dennis Misener asked:
> expression.GetOffset(pxOffset, pyOffset)
> ...
> My problem is how to the two floating point output values. See sample
> below... Any help would be certainly appreciated. Thanks
> ...
> subnode=node.addSubtopic 'label'
> subnode.invoke('getOffset',0.0,0.0) # How to get this to work???
> p [:offset,WIN32OLE::ARGV] # Seems to echo parameters
> ...
> [:offset, [0.0, 0.0]] << mirrors the supplied inputs
> G:/work/mindmanager/demo.rb:13:in `invoke': getOffset
> (WIN32OLERuntimeError)
> OLE error code:80040200 in MindManager.Application.6
> Error: 'this topic is not able to execute the call'
> HRESULT error code:0x80020009
> Exception occurred.from C:demo.rb:13:in `randomMap'
> from G:/work/mindmanager/demo.rb:11:in `times'
> from G:/work/mindmanager/demo.rb:11:in `randomMap'
> from G:/work/mindmanager/demo.rb:15:in `randomMap'
> from G:/work/mindmanager/demo.rb:11:in `times'
> from G:/work/mindmanager/demo.rb:11:in `randomMap'
> from G:/work/mindmanager/demo.rb:20

This shouldn't matter, but I usually write a method invocation like
subnode.invoke('getOffset',0.0,0.0)
as
subnode.GetOffset(0.0, 0.0)

You're right that WIN32OLE::ARGV is the way to get output parameters. The
problem seems to be with the method invocation itself failing with an error.

And it does looks from the stack trace as if the method has actually been
successfully executed at least once. Have you tried without the loop, from
IRB, for example?

Cheers,
Dave


Dennis Misener

3/29/2006 10:55:00 AM

0

In article <VcqWf.19175$dy4.3184@news-server.bigpond.net.au>,
dave@burt.id.au says...

> Dennis Misener asked:
> > expression.GetOffset(pxOffset, pyOffset)
> > ...
> > My problem is how to access the two floating point output values. See sample
> > below... Any help would be certainly appreciated. Thanks
> > ...
> > subnode=node.addSubtopic 'label'
> > subnode.invoke('getOffset',0.0,0.0) # How to get this to work???
> > p [:offset,WIN32OLE::ARGV] # Seems to echo parameters
> > ...
> > [:offset, [0.0, 0.0]] << mirrors the supplied inputs
> > G:/work/mindmanager/demo.rb:13:in `invoke': getOffset
> > (WIN32OLERuntimeError)
> > OLE error code:80040200 in MindManager.Application.6
> > Error: 'this topic is not able to execute the call'
> > HRESULT error code:0x80020009
> > Exception occurred.from C:demo.rb:13:in `randomMap'
> > from G:/work/mindmanager/demo.rb:11:in `times'
> > from G:/work/mindmanager/demo.rb:11:in `randomMap'
> > from G:/work/mindmanager/demo.rb:15:in `randomMap'
> > from G:/work/mindmanager/demo.rb:11:in `times'
> > from G:/work/mindmanager/demo.rb:11:in `randomMap'
> > from G:/work/mindmanager/demo.rb:20

> This shouldn't matter, but I usually write a method invocation like
> subnode.invoke('getOffset',0.0,0.0)
> as
> subnode.GetOffset(0.0, 0.0)

DM>Yes... tried it both ways... same result :-(

> You're right that WIN32OLE::ARGV is the way to get output parameters. The
> problem seems to be with the method invocation itself failing with an error.
>
> And it does looks from the stack trace as if the method has actually been
> successfully executed at least once. Have you tried without the loop, from
> IRB, for example?
DM>I found that odd too! Running inside IRB give the same results. Since
the real parameters should be RETURNED... I'm not sure passing IN real
constants as inputs is the answer... but unless I supply two REAL
argments it reports missing required parameters etc.
>
> Cheers,
> Dave
>
>
>

Dave Burt

3/29/2006 12:08:00 PM

0

Dennis Misener wrote:
>> > expression.GetOffset(pxOffset, pyOffset)
>> > subnode=node.addSubtopic 'label'
>> > subnode.invoke('getOffset',0.0,0.0)
>> > p [:offset,WIN32OLE::ARGV]

> DM>I found that odd too! Running inside IRB give the same results. Since
> the real parameters should be RETURNED... I'm not sure passing IN real
> constants as inputs is the answer... but unless I supply two REAL
> argments it reports missing required parameters etc.

Where and how does IRB die on this?

require 'win32ole'
MM=WIN32OLE.new("Mindmanager.Application")
MM.visible=true
node = MM.activeDocument.centralTopic
node.text='Main'
subnode=node.addSubtopic 'label'
subnode.getOffset(0.0, 0.0)
p [:offset,WIN32OLE::ARGV]

Cheers,
Dave


Masaki Suketa

3/29/2006 12:16:00 PM

0

Hello,

In message "Win32OLE output parameter access??"
on 06/03/29, Dennis Misener <dm@accesscable.net> writes:

> subnode.invoke('getOffset',0.0,0.0) # How to get this to work???

Try
include WIN32OLE::VARIANT
...
dispid = subnode.ole_method('getOffset').dispid
subnode._invoke(dispid, [0.0, 0.0], [VT_R4|VT_BYREF, VT_R4|VT_BYREF])
or
dispid = subnode.ole_method('getOffset').dispid
subnode._invoke(dispid, [0.0, 0.0], [VT_R8|VT_BYREF, VT_R8|VT_BYREF])

Regards,
Masaki Suketa


Dennis Misener

3/29/2006 2:46:00 PM

0

In article <200603291215.k2TCFRiK012334@userg501.nifty.com>,
masaki.suketa@nifty.ne.jp says...

Progress!!

Good news: It returns correct output parameters :-)
Bad news: It only works once!! :-( But that could my logic error or
Mindjets API problem.

Thanks for speedy+helpful response (from the Win32OLE father himself!!!)

---

require 'win32ole'

include WIN32OLE::VARIANT

MAX_DEPTH=5

MM=WIN32OLE.new("Mindmanager.Application")
MM.visible=true


def debug node
p [:node,node]
dispid=node.ole_method('getOffset').dispid
node._invoke(dispid, [0.0, 0.0], [VT_R4|VT_BYREF, VT_R4|VT_BYREF])
p [:offset,WIN32OLE::ARGV]
end

def randomMap node,label='Main',depth=5
node.text=label
depth.times do |index|
subnode=node.addSubtopic 'label'
debug subnode
randomMap subnode,'%s %02d' % [label,index+1],rand(depth)
end
end

node=MM.activeDocument.centralTopic
randomMap node

Produces:

c:\work>demo
[:node, #<WIN32OLE:0x2845008>]
[:offset, [30.0, -20.0]]
[:node, #<WIN32OLE:0x2844318>]
C:/Work/demo.rb:14:in `_invoke': _invoke (WIN32OLERuntimeError)
OLE error code:80040200 in MindManager.Application.6
Error: 'this topic is not able to execute the call'
HRESULT error code:0x80020009
Exception occurred from C:/Work/demo.rb:14:in `debug'
from C:/Work/demo.rb:22:in `randomMap'
from C:/Work/demo.rb:20:in `times'
from C:/Work/demo.rb:20:in `randomMap'
from C:/Work/demo.rb:23:in `randomMap'
from C:/Work/demo.rb:20:in `times'
from C:/Work/demo.rb:20:in `randomMap'
from C:/Work/demo.rb:28



> Hello,
>
> In message "Win32OLE output parameter access??"
> on 06/03/29, Dennis Misener <dm@accesscable.net> writes:
>
> > subnode.invoke('getOffset',0.0,0.0) # How to get this to work???
>
> Try
> include WIN32OLE::VARIANT
> ...
> dispid = subnode.ole_method('getOffset').dispid
> subnode._invoke(dispid, [0.0, 0.0], [VT_R4|VT_BYREF, VT_R4|VT_BYREF])
> or
> dispid = subnode.ole_method('getOffset').dispid
> subnode._invoke(dispid, [0.0, 0.0], [VT_R8|VT_BYREF, VT_R8|VT_BYREF])
>
> Regards,
> Masaki Suketa