Writes specified number of bytes to serial port.
| Delphi | function Write(DataBuffer: Pointer; BytesToWrite: Cardinal): Cardinal;
|
|---|---|
| BCBuilder | Cardinal Write(void * DataBuffer, Cardinal BytesToWrite);
|
DataBuffer
[in] Buffer of characters to be written. Use type-casting to convert it from void* or char*.
BytesToWrite
[in] Number of bytes to write to serial port.
Number of bytes written to serial port. It can write fewer bytes than requested; the return value must be noted, and the reminder of the operation should be retried when possible.
The method may throw exception. Refer to Handle errors sample for details.
In Visual Basic use WriteArray.
const
DataToWrite = 'String data';
begin
try
FTSPCControl1.Write(PChar(DataToWrite), length(DataToWrite));
except
on e:FTSPCException do
begin
application.MessageBox(PChar('Error: ' + inttostr(e.ErrorCode) +
' - ' + e.ErrorSource), 'Error!', MB_OK + MB_ICONERROR);
end;
end;
end;