'KCMLWritePort(iHandle, pData$, iCount)

Writes data to a serial or prallel port on the client previoulsy opened with KCMLOpenPort.

Arguments

INT()iHandle[in] Handle to the port returned from KCMLOpenPort.
DIM()pData$[in] The data to be written.
INT()iCount[in] The number of bytes to be written.

Returns

The number of bytes written. This can be less than the number requested.

Syntax

The following definition is built into KCML. You do not have to include it in your own code.

$DECLARE 'KCMLWritePort(INT(), DIM(), INT())

Remarks

KCMLWritePort writes data to a port previously opened with KCMLOpenPort. If writing to a serial port a timeout based on the baud rate and number of bytes to be written is used. It is possible that not all the data will be written, in which case the application should attempt to resend data from the appropriate point.

Note this function is synchronous and will not return until the timeout is reached or all the data is sent. Until the function returns the client will be unresponsive.

Example

	$DECLARE 'KCMLWritePort(INT(),DIM(),INT())
	$DECLARE 'KCMLOpenPort(STR())
	$DECLARE 'KCMLClosePort(INT())
	DIM Data$256
	DIM PortHandle
	DIM BytesWritten
	Data$ = "Some Data"
	REM Open COM2 at 9600 baud, 8 bits per character, no parity, one stop bit and hardware flow control
	PortHandle = 'KCMLOpenPort("COM2:9600,8,N,1,H")
	REM Write the data
	BytesWritten = 'KCMLWritePort(PortHandle, Data$, LEN(Data$))
	REM The amount of data written may be less than requested.
	REM A robust application should attempt to ensu re all data is sent
	REM Finally close the port
	'KCMLClosePort(PortHandle)

Further Information

IntroducedKCML 6.20
CompatibilityKClient

See Also

KCMLClosePort, KCMLDebugBackProcess, KCMLGetClientIP_TOS, KCMLOpenPort, KCMLReadPort, KCMLSetClientIP_TOS, KCMLWritePortName

Index of internal $DECLARE functions