[python-win32] Input-only vs. In/Out Function Parameters

Smith, Brian (CR) smithbk at aecl.ca
Mon Oct 2 22:23:40 CEST 2006


Hi,
 
Just thought I'd bump this to see if I could get a response...
 
Brian
 
>
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20061002/d224b33b/attachment.html 


More information about the Python-win32 mailing list