Forum: Ruby WIN32OLE output params: Type mismatch and bad variable type

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
E80599da988fad4ffe6fe9213ca2c5a8?d=identicon&s=25 Jeff Schuss (fulaftrbrnr)
on 2014-06-17 16:41
Hello all,

I'm trying to make an API call for an application designed to work with
VB code, but I'm running into issues with variable types of an API
function that has 6 input args (STRING, 4 INT4s, BOOL) and 2 output args
(2 OBJECTs).

Here's my code and everything I've tried thus far based on what I've
read from other posts with similar issues:


require 'win32ole'

femap = WIN32OLE::connect('femap.model')

#Would like to do this:
vset, oset = femap.feSet, femap.feSet
arg0 = 'some string'
arg1, arg2, arg3, arg4 = 0, 0, 4, 7
arg5 = true
femap.feSelectOutput( arg0, arg1, arg2, arg3, arg4, arg5, vset, oset )

#results in:
#WIN32OLERuntimeError: (in OLE method `feSelectOutput': )
#    OLE error code:0 in <Unknown>
#      <No Description>
#    HRESULT error code:0x80020005
#      Type mismatch.
#        from interfaceloads.rb:30:in `method_missing'
#        from interfaceloads.rb:30:in `<top (required)>'
#        from (irb):49:in `load'
#        from (irb):49
#        from C:/Ruby/bin/irb:12:in `<main>'


#Have tried this as well: (20426 is the dispid)
femap._invoke( 20426, [ '', 0, 0, 4, 7, true, nil, nil ], \

#results in same error


#(1)If I change the VT_VARIANTs to VT_NULL or VT_EMPTY I get the same
#(2)If I change the nils to I get the same error.
#(3)If I do both (1) & (2) I get a different error:
#WIN32OLERuntimeError: (in OLE method `<dispatch id:20426>': )
#    OLE error code:0 in <Unknown>
#      <No Description>
#    HRESULT error code:0x80020008
#      Bad variable type.
#        from interfaceloads.rb:24:in `_invoke'
#        from interfaceloads.rb:24:in `<top (required)>'
#        from (irb):54:in `load'
#        from (irb):54
#        from C:/Ruby/bin/irb:12:in `<main>'


Please help!!!

Thank you,

Jeff S

Edit: I can't count
This topic is locked and can not be replied to.