Asynchronous UDF on DDEExecute() Is Passed Six Parameters

Last reviewed: April 29, 1996
Article ID: Q107401
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, and 2.5b

SUMMARY

The "Language Reference" manual and the Help file incorrectly state that the asynchronous user-defined function (UDF) option of the DDEExecute() command is passed five parameters. In fact, this option requires six parameters.

MORE INFORMATION

The syntax of the DDEEXecute() command is:

   DDEExecute(<expN>, <expC1>[, <expC2>])

The third parameter of this command is an optional asynchronous UDF that permits asynchronous command execution requests. It returns either a transaction number or, if there is an error, it returns -1.

The "Language Reference" (page L3-364) and the Help file state that:

   If <expC3> is omitted, a client waits for the period specified
   with DDESetOption( ). If you specify the name of a UDF with
   <expC3>, client program execution continues immediately after
   the command execution request is made.

   When the server application finishes executing the command,
   the UDF specified with <expC3> is executed. The UDF is
   passed five parameters... .

NOTE: The syntax in the "Language Reference" and Help file incorrectly adds an additional <expCn>, which is why the text refers to "<expC3>." The syntax shown in this article is correct; wherever "<expC3>" is mentioned in the manual and Help file, substitute "<expC2>."

However, the asynchronous UDF specified in the optional expression <expC2> is actually passed six parameters in this order:

     Channel Number
     Action
     Item
     Data
     Format
     Transaction Number

The following code example demonstrates the problem with passing five parameters to the asynchronous UDF. The code assumes that WINWORD.EXE and the file, GRAPHICS.DOC, are located in the directory C:\WORD20C.

NOTE: The second parameter of the DDEExecute() function, '[FileOpen "graphics.doc"]', requires single quotation marks for the outer delimiter and double quotation marks for the inner delimiter.

   RUN/N c:\word20c\WINWORD.EXE
   channel=DDEInitiate('WinWord','System')
   IF channel>=0
      =DDEExecute(channel,'[FileOpen "c:\word20c\GRAPHICS.DOC"]',;
           'asyncUDF')
      WAIT WINDOW "Calling asynchronous UDF"
   ENDIF
   =DDETerminate(channel)

   PROCEDURE asyncUDF    && asynchronous transaction UDF
   PARAMETERS mChannel, mAction, mItem, mData, mTransnum
   DISPLAY MEMORY LIKE m*
   WAIT
   RETURN .T.

An error message, "Wrong number of parameters," will occur on the PARAMETERS statement in the asynchronous UDF. When the error occurs, choose the Cancel button in the error message box. To correct this error, add a sixth parameter to the PARAMETERS statement above. For example,

   PARAMETERS mChannel, mAction, mItem, mData, mFormat, mTransnum


Additional reference words: FoxWin 2.50 2.50a 2.50b DDE DDEExecute
asynchronous docerr errmsg err msg dynamic data exchange
KBCategory: kbinterop kbprg kbdocerr kberrmsg kbcode
KBSubcategory: FxinteropDde


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 29, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.