Win32OLE output parameter access??

D

Dennis Misener

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 [:eek:ffset,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:

[:eek:ffset, [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
 
D

Dave Burt

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 [:eek:ffset,WIN32OLE::ARGV] # Seems to echo parameters
...
[:eek:ffset, [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
 
D

Dennis Misener

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 [:eek:ffset,WIN32OLE::ARGV] # Seems to echo parameters
...
[:eek:ffset, [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.
 
D

Dave Burt

Dennis said:
expression.GetOffset(pxOffset, pyOffset)
subnode=node.addSubtopic 'label'
subnode.invoke('getOffset',0.0,0.0)
p [:eek:ffset,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 [:eek:ffset,WIN32OLE::ARGV]

Cheers,
Dave
 
M

Masaki Suketa

Hello,

In message "Win32OLE output parameter access??"
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
 
D

Dennis Misener

Progress!!

Good It returns correct output parameters :)
Bad 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 [:eek:ffset,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>]
[:eek:ffset, [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??"
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
 

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,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top