Microsoft KB Archive/107401

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Asynchronous UDF on DDEExecute() Is Passed Six Parameters

ID: Q107401

2.50 2.50a 2.50b WINDOWS kbinterop kbdocerr

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 kbdocerr KBSubcategory: FxinteropDde

Keywords          : kbcode kberrmsg FxinteropDde 
Version           : 2.50 2.50a 2.50b
Platform          : WINDOWS

Last Reviewed: May 22, 1998
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.