Sending commands using DDE

Previous Top Next

Sending commands using DDE (from Excel, Access ... any DDE enabled application).

CPS Plus supports the following server / topic pair for sending commands: ("CPSPLUS", "DRIVER")

The following code shows how to transmit a string to the serial port (COM1) from Excel.

Example 1:

chan = DDEInitiate("CPSPLUS", "DRIVER")
DDEExecute chan, "[WriteToCOM1(123.8913)]"   send 123.89 <cr> to serial port 1
DDETerminate chan


DDE commands have the following syntax:

[WriteToCOMx (string out)]

x   - represents port number where you want to send data.
In the Excel example above string out is 123.0013.

To send the same string to different port just change x                to the requered port number.

More Examples:

Example 2:

chan = DDEInitiate("CPSPLUS", "DRIVER")
DDEExecute chan, "[WriteToCOM2(SELFTEST1310)]"     ' send SELFTEST <cr> <lf> to serial port 2
DDETerminate chan

Example 3:

chan = DDEInitiate("CPSPLUS", "DRIVER")
DDEExecute chan, "[WriteToCOM1(ReadS113)]"     ' send ReadS1 <cr> to serial port 1
DDETerminate chan

<cr> represent carriage return and <lf> represents line feed.


Note: CPS must be running in DDE Mode in order to read and write to serial port using DDE.