Visual Fox Pro: Communicating with Devices through WinWedge

The following procedure demonstrates how to transmit a string out the serial port by sending a DDE command from FoxPro to WinWedge.

PROCEDURE TransmitTesting

CmdString="[SENDOUT('testing 123',13)]"
*** transmit the string "testing 123" followed by a carriage return (ascii 13)
gnChanNum = DDEInitiate('WinWedge', 'COM2')
IF gnChanNum != -1
glExecute = DDEExecute(gnChanNum, CmdString)
= DDETerminate(gnChanNum) && Close the channel
ENDIF

RETURN

*** the following procedure is a variation of the above procedure that transmits a 

*** string passed as a parameter to the procedure (gData) 

PROCEDURE TransmitData 

PARAMETERS gData
cmdstring="[SENDOUT(' " & gData & " ' )]"
*** transmit the string passed in the variable gData
*** note the use of both single and double quotes around the gData variable
*** refer to the syntax for the SENDOUT command in the Wedge manual for details
gnChanNum = DDEInitiate('WinWedge', 'COM2')
IF gnChanNum != -1
glExecute = DDEExecute(gnChanNum, CmdString)
= DDETerminate(gnChanNum) && Close the channel
ENDIF
RETURN

Contact Us