[Up] [Contents] [Index] [Summary]

3.40.1 DDE client interface

The DDE client interface allows Prolog to talk to DDE server programs. We will demonstrate the use of the DDE interface using the Windows PROGMAN (Program Manager) application:

1 ?- open_dde_conversation(progman, progman, C). C = 0 2 ?- dde_request(0, groups, X) --> Unifies X with description of groups 3 ?- dde_execute(0, '[CreateGroup("DDE Demo")]'). Yes 4 ?- close_dde_conversation(0). Yes

For details on interacting with progman, use the SDK online manual section on the Shell DDE interface. See also the Prolog library(progman), which may be used to write simple Windows setup scripts in Prolog.

open_dde_conversation(+Service, +Topic, -Handle)
Open a conversation with a server supporting the given service name and topic (atoms). If successful, Handle may be used to send transactions to the server. If no willing server is found this predicate fails silently.

close_dde_conversation(+Handle)
Close the conversation associated with Handle. All opened conversations should be closed when they're no longer needed, although the system will close any that remain open on process termination.

dde_request(+Handle, +Item, -Value)
Request a value from the server. Item is an atom that identifies the requested data, and Value will be a string (CF_TEXT data in DDE parlance) representing that data, if the request is successful. If unsuccessful, Value will be unified with a term of form error(<Reason>), identifying the problem. This call uses SWI-Prolog string objects to return the value rather then atoms to reduce the load on the atom-space. See section 3.19 for a discussion on this data type.

dde_execute(+Handle, +Command)
Request the DDE server to execute the given command-string. Succeeds if the command could be executed and fails with error message otherwise.

dde_poke(+Handle, +Item, +Command)
Issue a POKE command to the server on the specified Item. Command is passed as data of type CF_TEXT.