Title: Input-only vs. In/Out Function Parameters

Hello,

I am new to COM programming and have a question about function
parameters when implementing a COM object in Python.

After reading "Python Programming on Win32", I have managed to create a
working COM object, where "working" is defined as "I can use it from
Excel VBA".

I have a function like this:

def func(self, in1, inout1, in2, inout2)

where the in* parameters are input only and inout* are input and output.
At the end of the function I return an error code and new values for the
in/out parameters. I.e.:

return( errorCode, new_inout1, new_inout2 )

This seems to work fine if it is called from VBA as

    errorCode = object.func( CONSTANT_1, var1, CONSTANT_2, var2 )

or

    errorCode = object.func( 42, var1, 7.4, var2 )

but it breaks if the VB program does this:

    c1 = CONSTANT_1  ' c1 is a previously declared variable
    c2 = 7.4         ' c2 is a previously declared variable
    errorCode = object.func( c1, var1, c2, var2 )

because c1 will then be assigned new_inout1 and var1 will be assigned
new_inout2, while c2 and var2 will not be assigned anything.

Short of telling the VB programmer "Don't do that", how do I prevent
this problem?

Thanks,
Brian




CONFIDENTIAL AND PRIVILEGED INFORMATION NOTICE

This e-mail, and any attachments, may contain information that
is confidential, subject to copyright, or exempt from disclosure.
Any unauthorized review, disclosure, retransmission, 
dissemination or other use of or reliance on this information 
may be unlawful and is strictly prohibited.  

AVIS D'INFORMATION CONFIDENTIELLE ET PRIVILÉGIÉE

Le présent courriel, et toute pièce jointe, peut contenir de 
l'information qui est confidentielle, régie par les droits 
d'auteur, ou interdite de divulgation. Tout examen, 
divulgation, retransmission, diffusion ou autres utilisations 
non autorisées de l'information ou dépendance non autorisée 
envers celle-ci peut être illégale et est strictement interdite.
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to