DDERequest( ) Function

Example   See Also

Requests data from a server application in a dynamic data exchange (DDE) conversation.

Syntax

DDERequest(nChannelNumber, cItemName [, cDataFormat [, cUDFName]])

Returns

Character

Arguments

nChannelNumber

Specifies the channel number of the server application.

cItemName

Specifies the item name. The item name is application-specific and must be understood by the application. For example, Microsoft Excel uses row and column notation to refer to cells in a worksheet. The item name R1C1 designates the cell in the first row and first column of the worksheet.

cDataFormat

Specifies a format for the data requested. The default format is CF_TEXT. In this format, fields are delimited with tabs and records are delimited with a carriage return and a line feed.

cUDFName

Allows an asynchronous data transfer. If you omit cUDFName, Visual FoxPro waits for the data from the server for the period specified with DDESetOption( ). If you specify the name of a user-defined function with cUDFName, Visual FoxPro continues program execution immediately after the request is made.

When the data is available from the server application, the user-defined function specified with cUDFName is executed. The user-defined function is passed six parameters in this order:

Parameter Contents
Channel Number The channel number of the server application.
Action XACTCOMPLETE (successful transaction).
XACTFAIL (failed transaction).
Item The item name; for example, R1C1 for a Microsoft Excel worksheet cell.
Data The new data (REQUEST) or data passed (POKE or EXECUTED).
Format The data format; for example, CF_TEXT.
Transaction Number The transaction number returned by DDERequest( ).

Use DDEAbortTrans( ) to cancel an uncompleted transaction. If the transaction fails, you can use DDELastError( ) to determine why it failed.

When you include cUDFName, DDERequest( ) returns a transaction number equal to or greater than 0 if successful, or –1 if an error occurs.

Remarks

Before you can request data using DDERequest( ), you must establish a channel to the server application with DDEInitiate( ).

If the request for data is successful, DDERequest( ) returns the data as a character string. If the request fails, DDERequest( ) returns an empty string and DDELastError( ) returns a nonzero value. If you include the asynchronous user-defined function cUDFName, DDERequest( ) returns a transaction number if successful, or –1 if an error occurs.