| Dart Home | PowerTCP Winsock for ActiveX | Custom Development | Reply | PowerTCP Winsock for ActiveX Topics | Forums |
| Author | Forum: PowerTCP Winsock for ActiveX Topic: Gathering data from Search() method. |
| pursuit-julian From: winnipeg, MB USA Posts: 1 Member Since: 06/14/04 |
posted June 14, 2004 4:20 PM I'm unsure how to read data returned from a TCP connection. In the code below, I send out 5 bytes (CTRL+B, three byte command string and a CR) and receive a variable number of bytes back. I have been able to confirm that I am receiving the correct number of bytes for a given command and that the command is returning the correct data, but cannot seem to collect these bytes and convert them to a string. The code always breaks with an error at the Search() method call of the TCP control named OlePointSix. The error is: "OLE IDispatch Exception code 0 from Dart.Tcp.1: Parameter 1 of the method used is invalid or not appropriate..." My FoxPro 8 Code is as follows: ---START OF CODE--- LPARAMETERS lnNum LOCAL lcCatchData as Variant debugmode() * Read the remote device IP address from a text box and remove the leading and trailing spaces. lcRemoteAddress = ALLTRIM(this.itextbox1.Value) IF VARTYPE(this.itextbox2.Value) = "N" * Read the port number entered. lnRemotePort = this.itextbox2.Value ELSE * convert the port number value to a number if required. lnRemotePort = VAL(this.itextbox2.Value) ENDIF * Read the command string enetered in a form textbox. lcCommandString = ALLTRIM(this.itextbox3.Value) IF lnNum = 1 * Create a connection to the correct port on the remote device. This.OlePointSix.connect(lcRemoteAddress,lnRemotePort) * Send CTRL+B followed by the string command followed by CR. lnSendResponse = this.OlePointSix.OBJECT.Send(CHR(2)+lcCommandString+CHR(13)) * Look for a CR in the returned bytes. lnSearchResponse = this.OlePointSix.OBJECT.Search(lcCatchData,CHR(13)) * Place the returned bytes into a textbox for display. this.itextbox4.Value = lcCatchData this.OlePointSix.Close ENDIF ---END OF CODE--- Julian Nedohin-Macek Winnipeg, MB |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted June 14, 2004 4:43 PM Make sure you initialize the Variant to a string before passing it. Something like this: LOCAL lcCatchData as Variant lcCatchData = "" |
| Reply | PowerTCP Winsock for ActiveX Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|