COM: Returning IDispatch or NULL

Juan Carlos CORUÑA jcc at ibdosnorte.com
Tue Sep 24 03:53:43 EDT 2002


Mark Hammond <mhammond at skippinet.com.au> wrote in message news:<Z5Oj9.12374$6g7.37565 at news-server.bigpond.net.au>...
> Juan Carlos CORUÑA wrote:
> > Hello,
> > 
> > I'm trying to develop a COM Server in python, that has a method that
> > returns an IDispatch object but sometimes it must return nothing. See
> > the following example programmed in C/SIDE (Microsoft Navision
> > Financials ERP):
> > 
> > --->
> > otherCOMServer := COMServer.returnOtherCOMServer();
> > IF ISCLEAR(otherCOMServer) THEN MESSAGE('otherCOMServer is clear');
> > <----
> > 
> > Definition of ISCLEAR (extracted from MS Navision help):
> >   The return value is TRUE if:
> >     -the automation variable has not been created. See CREATE.
> >     -the automation variable has been cleared. See CLEAR.
> >     -the automation variable has been assigned NULL by an automation
> > server.
> > 
> > I thing that in this case I must assign NULL to the otherCOMServer
> > variable in order to keep the otherCOMServer variable CLEARED.
> > What must I return from "COMServer.returnOtherCOMServer()" method to
> > assign NULL?
> > I have tried:
> >   return None
> >   return wrap(None)
> >   return 1==0
> >   return
> > 
> > but without success. The environment responds "data type not
> > supported".
> 
> None is the way to do this.  What responds "data type not supported"? 
> Have you registered your object for debugging and seen the output? 
> There may be a traceback printed.
> 
> Mark.

After executing "return None" Navision responds "This data type is not
supported by C/SIDE".

The debugging output is correct:

OutMessage created <NAVISIONSPREADLib.OutMessage instance at
0x02406260>
Object with win32trace dispatcher created
(object=<NAVISIONSPREADLib.OutMessage instance at 0x02406260>)
Returning wrapped <PyIDispatch at 0x24fde14 with obj at 0x2406468>
in _Invoke_ with 1000 1024 1 (<PyIDispatch at 0x24fde14 with obj at
0x1caad68>,)
in _Invoke_ with 1002 1024 1 (1000,)
returning None

The invoke with 1002 is the call to the method that returns NULL or an
object after 1000 ms of timeout.



More information about the Python-list mailing list