RemoteQueryHandler() 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

A special function, called when a MapBasic program acts as a DDE server, and the DDE client performs a "peek" request. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

Declare Function RemoteQueryHandler() As String 

Function RemoteQueryHandler() As String 
	 statement_list 
End Function

statement_list is a list of statements to execute upon receiving a peek request.

Description

The RemoteQueryHandler() function works in conjunction with DDE (Dynamic Data Exchange). For an introduction to DDE, see the MapBasic User Guide. An external application can initiate a DDE conversation with your MapBasic program. To initiate the conversation, the external application uses "MapInfo" as the DDE application name, and it uses the name of your MapBasic application as the DDE topic. Once the conversation is initiated, the external application (the client) can issue peek requests to request data from your MapBasic application (the server).

To handle peek requests, include a function called RemoteQueryHandler() in your MapBasic application. When the client application issues a peek request, MapInfo Pro automatically calls the RemoteQueryHandler() function. The client's peek request is handled synchronously; the client waits until RemoteQueryHandler() returns a value.

Note: The DDE client can peek at the global variables in your MapBasic program, even if you do not define a RemoteQueryHandler() function. If the client issues a peek request using the name of a MapBasic global variable, MapInfo Pro automatically returns the global's value to the client instead of calling RemoteQueryHandler(). In other words, if the data you want to expose is already stored in global variables, you do not need RemoteQueryHandler().

Example

The following example calls the CommandInfo() function to determine the item name specified by the DDE client. The item name is used as a flag; in other words, this program decides which value to return based on whether the client specified "code1" as the item name.

Function RemoteQueryHandler() As String
	Dim s_item_name As String

	s_item_name = CommandInfo(CMD_INFO_MSG)

	If s_item_name = "code1" Then
		RemoteQueryHandler = custom_function_1()
	Else 
		RemoteQueryHandler = custom_function_2()
	End If 

End Function

See Also:

DDEInitiate() function, RemoteMsgHandler procedure