SleepingMonk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, relitivly new to the wonderful world of perl (4 weeks to be exact),so this may well be a stupid question, feel free to point this out at your leasure. Anyway, to the matter in hand: I am using win32::ole::variant to set up a 2 byte signed variant variable

i.e.
my $registerIndex = Win32::OLE::Variant::Variant(Win32::OLE::Variant:: +VT_I2|Win32::OLE::Variant::VT_BYREF,0);
This variant is needed as i call another program, that i use to communicate with the parallel port (program is called v2wReg, and i think it is exclusive to the company i am doing a summer placement for, but could be mistaken), and in its documentation it dictates that i MUST pass a variant into it in order to read from the register the parallel port is connected to.

The documentation looks like this -:

VARIANT ReadRegisterNoWrite( LONG nDevLocation,VARIANT* nIndex,VARIANT +* nValue,VARIANT* bAutoIncrement);
Thus indicating which variables go where. I know that the first two variant variables will return 1 byte and the autoincrment variant will return 1 bit.

No matter what i pass into the function ReadRegisterNoWrite i get no return (i.e. nothing happens to the variables that i pass in) and the same error (only with 'use warnings;' in my code though) of:

Win32::OLE(0.1501) error 0x80020005: "Type mismatch" in METHOD/PROPERT +YGET "ReadRegister" argument 3 at trial.pm line 49
I am totally stumped as to how to avoid this error and get a good reaading from the register so any light anyone one of you monkees could spread onto this problem would be much appreciated.

cheers.

The SleepingMonk

p.s. if it helps any I am using i2c to talk to the register at the parallel port. (v2wReg is a program that allows perl to communicate with i2c devices)

update (broquaint): added <code> tags

Replies are listed 'Best First'.
Re: WIN32::OLE::VARIANT --- the destroyer of souls ???
by RMGir (Prior) on Jul 16, 2003 at 13:06 UTC
    You're showing us how you create $registerIndex, good.

    Now is that what you're passing as nIndex? If so, we need to see what you're passing as nValue, which is the problem argument according to your error message.

    You should be able to get this down to 5-20 lines of perl, initializing your system, setting up your 3 variants and then invoking ReadRegisterNoWrite. What happens in that case?
    --
    Mike

      The error message should say "type mismatch......at arguement 2" sorry i copied it wrongly, but i use the same bit of code for all 3 variant variables.

      hope this helps

      cheers

      SleepingMonk

      p.s. would it be helpful if i gave you the entire code ?
        Probably not; I (happily) haven't had to fight OLE battles for a few years...

        I seem to recall that there's a DDESpy equivalent for OLE (or maybe you can use DDESpy to watch OLE traffic?). If so, you might be able to watch what a test VB application sends for that call, and then duplicate it yourself...

        My only other suggestion would be to use VT_UI1 instead of VT_I2, and see if that works, since you're only expecting one byte to be returned and not 2... That's based on a quick look at the docs, not any personal expertise with this module, I'm afraid.
        --
        Mike