Win32OLE output parameter access??

Discussion in 'Ruby' started by Dennis Misener, Mar 29, 2006.

  1. 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
    Dennis Misener, Mar 29, 2006
    #1
    1. Advertising

  2. Dennis Misener

    Dave Burt Guest

    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
    Dave Burt, Mar 29, 2006
    #2
    1. Advertising

  3. In article <VcqWf.19175$>,
    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 [: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.
    >
    > Cheers,
    > Dave
    >
    >
    >
    Dennis Misener, Mar 29, 2006
    #3
  4. Dennis Misener

    Dave Burt Guest

    Dennis Misener wrote:
    >> > 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
    Dave Burt, Mar 29, 2006
    #4
  5. Hello,

    In message "Win32OLE output parameter access??"
    on 06/03/29, Dennis Misener <> 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
    Masaki Suketa, Mar 29, 2006
    #5
  6. In article <>,
    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 [: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??"
    > on 06/03/29, Dennis Misener <> 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, Mar 29, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ara.T.Howard
    Replies:
    2
    Views:
    161
    Ara.T.Howard
    Aug 7, 2005
  2. Dave Burt
    Replies:
    9
    Views:
    163
  3. Masaki Suketa
    Replies:
    4
    Views:
    371
    Dave Burt
    Mar 27, 2006
  4. zxem
    Replies:
    1
    Views:
    225
  5. Mitchell Hashimoto

    Complicated output parameter in WIN32OLE

    Mitchell Hashimoto, Apr 8, 2010, in forum: Ruby
    Replies:
    3
    Views:
    97
    Chuck Remes
    Apr 8, 2010
Loading...

Share This Page