vfp

* Open Connection to scale

nHandle = fopen("com1:9600,n,8,1",2)

=fflush(nHandle)

* Send Command

nRet = fputs(nHandle,"GIVE_WEIGHT")

=fclose(nHandle)

* Read Result

nHandle = fopen("com1:9600,n,8,1",0)

cScaleValue = ""

do while true

cRead = fread(nHandle,1)

if cread = chr(13)

exit

else

cScaleValue = cScaleValue + cRead

endif

enddo

=fclose(nHandle)

---------------

*** OLE ??? ***

* The following example shows how to perform basic serial port

communications:

* Use COM1.

this.CommPort = 1

* 9600 baud, no parity, 8 data, and 1 stop bit.

this.Settings = "300,e,7,2"

* Tell the control to read entire buffer when Input is used.

this.InputLen = 0

* Open the port.

this.PortOpen = .T.

* Send the attention command to the modem.

this.Output = "AT" + CHR(13)

* Wait for data to come back to the serial port.

ii =1

DO WHILE this.InBufferCount <= 2

* Read the "OK" response data in the serial port.

InString = this.Input

*? instring

* IF InString == "OK"

* EXIT

* ENDIF

ii = ii +1

if ii=20

exit

endif

ENDDO

* Close the serial port.

Comm1.PortOpen = .F.