DDERequest$() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Returns a data value obtained from a DDE conversation.

Syntax

DDERequest$( channel, itemname )

channel is an integer channel number returned by the DDEInitiate() function.

itemname is a string representing the name of an item in the server application.

Return Value

String

Description

The DDERequest$() function returns a string of information obtained through a DDE conversation. If the request is unsuccessful, the DDERequest$() function returns a null string.

The channel parameter must correspond to the number of a channel which was opened through the DDEInitiate() function.

The itemname parameter should identify an item which is appropriate for the specified channel. Different DDE applications support different item names; to learn what item names are supported by a particular Windows application, refer to the documentation for that application.

The following table lists some topic and item combinations that can be used when conducting a DDE conversation with Microsoft Excel as the server:

Topic name Item names to use with DDERequest$()
"System" "Systems" returns a list of item names accepted under the "System" topic;

"Topics" returns a list of DDE topic names accepted by Excel, including the names of all open worksheets;

"Formats" returns a list of clipboard formats accepted by Excel (for example, "TEXT BITMAP ...")

wks (name of a worksheet in use) A string of the form R1C1 (for Row 1, Column 1) returns the contents of that cell

Note: Through the DDERequest$() function, one MapBasic application can observe the current values of global variables in another MapBasic application. The following table lists the topic and item combinations that can be used when conducting a DDE conversation with MapInfo Pro as the server
Topic name item names to use with DDERequest$()
"System" "Systems" returns a list of item names accepted under the "System" topic;

"Topics" returns a list of DDE topic names accepted by MapInfo Pro, which includes the names of all MapBasic applications currently in use;

"Formats" returns a list of clipboard formats accepted by MapInfo Pro ("TEXT");

"Version" returns the MapInfo version number, multiplied by 100.

mbx (name of .MBX in use) "{items}" returns a list of the names of global variables in use by the specified MapBasic application; specifying the name of a global variable lets DDERequest$() return the value of the variable

Error Conditions

ERR_CMD_NOT_SUPPORTED (642) error generated if not running on Windows.

ERR_INVALID_CHANNEL (696) error if the specified channel number is invalid.

ERR_CANT_INITIATE_LINK (698) error generated if MapBasic cannot link to the topic.

Example

The following example uses the DDERequest$() function to obtain the current contents of the first cell in an Excel worksheet. Note that this example will only work if Excel is already running.

Dim i_chan_num As Integer
Dim s_cell As String
i_chan_num = DDEInitiate("EXCEL", "Sheet1") 
s_cell = DDERequest$(i_chan_num, "R1C1") 

The following example assumes that there is another MapBasic application currently in use―"Dispatch"―and assumes that the Dispatch application has a global variable called Address. The example below uses DDERequest$() to obtain the current value of the Address global variable.

Dim i_chan_num As Integer, s_addr_copy As String 
i_chan_num = DDEInitiate("MapInfo","C:\DISPATCH.MBX")
s_addr_copy = DDERequest$(i_chan_num, "Address") 

See Also:

DDEInitiate() function