DDE Interface
DDE (Dynamic Data Exchange) is a dynamic exchange of data between Windows applications. A client application that initiates the exchange is required. A server application is also required to serve the requested information or run the requested actions. FlexPro can function as a server for DDE communication and can run commands that are sent from the client. A typical client would be, for instance, a Visual Basic application that accepts data from a device, saves the information in a file and remotely controls FlexPro for the evaluation and documentation of the data.
Note: The latest FlexPro Automation interface offers several more comprehensive options for communication between FlexPro and a client application. It is recommended that you use the DDE interface.
Connection Setup, Interaction and Termination
To be able to run FlexPro functions from other Windows programs that support DDE communication as a client, you first have to set up a DDE connection. This is achieved by sending the message WM_DDE_INITIATE, where "FlexPro" or "FlexPro 13" is specified as the application and "SYSTEM" is specified as the topic. If a connection is successfully made, there is a acknowledgement by way of a WM_DDE_ACK message. If you have provided a version number, the connection will only be successful when this particular version of FlexPro is installed.
Any number of commands can then be sent to FlexPro to be run with the help of the message WM_DDE_EXECUTE. It is also possible to send several commands together with a single message. When a command is correctly received, this is confirmed by a WM_DDE_ACK message. There is also a confirmation if the commands received cannot be run correctly.
When the client application has sent all of the desired commands to FlexPro, the DDE communication is ended by sending the WM_DDE_TERMINATE message.
Visual Basic Example
Here is a brief example of how DDE communication used for printing a document can be achieved by means of a client application in Visual Basic:
Sub Document_Click ()
Const NONE = 0, LINK_MANUAL = 2 ' Constants
Dim Cmd, Z ' Variables
' Combine commands:
Cmd = "[open(""c:\Project Databases\Test.fpd"")]"
Cmd = Cmd & "[openobject(""Document.doc"")]"
Cmd = Cmd & "[update]"
Cmd = Cmd & "[print]"
Cmd = Cmd & "[closeobjects]"
Cmd = Cmd & "[close]"
If Text1.LinkMode = NONE Then
Z = Shell("FlexPro", 4) ' Start FlexPro
Text1.LinkTopic = "FlexPro 11|System" ' Set LinkTopic
Text1.LinkItem = "" ' LinkItem
Text1.LinkMode = LINK_MANUAL ' LinkMode
End If
Text1.LinkExecute Cmd ' Execute Commands
End Sub
This subroutine can be called, for instance, if the source data on which the document is based has been overwritten by a data acquisition program.
With the commands available, it is possible to open and close project databases, to open, update, print and close an object in the project database, as well as to activate folders.
The commands listed here can, as described above, be sent to FlexPro with a WM_DDE_EXECUTE message, individually or bundled.
Note: In FlexPro it is basically possible to work with several project databases simultaneously. This is not possible in connection with DDE communication, since the project database referred to would have to be specified with every command, except when opening a project database.