Creates or releases a topic name from a service name in a dynamic data exchange (DDE) conversation.
Syntax
DDESetTopic(cServiceName, cTopicName [, cUDFName])
Returns
Logical
Arguments
cServiceName
Specifies the service name. Additional service names can be created with DDESetService( ).
cTopicName
Specifies the topic name to create or release. If you include cUDFName, DDESetTopic( ) creates the topic name cTopicName. If you omit cUDFName, the topic name cTopicName is released. If cTopicName is an empty string, the user-defined function specified with cUDFName is executed for any topic name that isn't explicitly declared.
cUDFName
Specifies the name of the user-defined function executed when a client application makes a request to the topic name. If you omit cUDFName, the topic name cTopicName is released from the service name.
When the user-defined function is executed, it is passed the following six parameters in the order given below:
Parameter | Contents |
Channel Number | The client channel number. |
Action | ADVISE, EXECUTE, INITIATE, POKE, REQUEST, or TERMINATE. |
Item | The item name; for example, R1C1 for a Microsoft Excel worksheet cell. |
Data | Data from the client. |
Format | The data format; for example, CF_TEXT. |
Advise Status | The link type (0 = manual, 2 = notify or automatic). |
The values of the Item, Data, and Advise Status parameters depend on the Action parameter. The following table lists the Action parameter values and the values contained in the Item, Data, and Advise Status parameters. A dash (–) indicates that the parameter value is the empty string.
Action value | Item value | Data value | Advise status |
INITIATE | – | Topic name | – |
TERMINATE | – | – | – |
POKE | Item name | New data | – |
REQUEST | Item name | – | – |
EXECUTE | – | New command | – |
ADVISE | Item name | – | Link type |
If the user-defined function successfully handles the client request, the user-defined function should return true (.T.). If the request can't be handled or an error occurs, the user-defined function should return false (.F.). If false is returned when the Action parameter value is INITIATE, the client topic name request is rejected. If false is returned when the value is POKE, REQUEST, or EXECUTE, the request is ignored. If false is returned when the value is ADVISE, the client request for a notify or automatic link is rejected.
Remarks
After a topic name is created, any client requests to the topic name cause Visual FoxPro to execute the user-defined function specified with cUDFName. The user-defined function is passed a set of parameters whose values are determined by the client request. The user-defined function return value is passed to the client with DDEPoke( ). The return value is a logical value indicating whether the topic name can provide the service requested by the client.
DDESetTopic( ) returns true (.T.) if it successfully creates or releases the topic name. It returns false (.F.) if the topic name cannot be created or released. Use DDELastError( ) to determine why a topic name cannot be created or released.