WriteArray Method

Writes specified number of bytes from array to serial port.

Syntax

Delphi
function WriteArray(DataBuffer: array of byte; BytesToWrite: Cardinal): Cardinal; 
BCBuilder
Cardinal WriteArray(const Byte * DataBuffer, const int DataBuffer_Size, Cardinal BytesToWrite); 

Parameters

DataBuffer

[in] SafeArray of bytes to write.

BytesToWrite

[in, optional] Number of bytes to write to serial port.

Return

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.

Errors

The method may throw exception. Refer to Handle errors sample for details.

Code Example

var
	DataToWrite: array[1..5] of byte;
	i: integer;
begin
	try
		for i := 0 to Length(DataToWrite)-1 do
			DataToWrite[i] := i;

		FTSPCControl1.WriteArray(DataToWrite);

	except
		on e:FTSPCException do
		begin
			application.MessageBox(PChar('Error: ' + 
				inttostr(e.ErrorCode) + ' - ' +
				e.ErrorSource), 'Error!', MB_OK + 
				MB_ICONERROR);
		end;
	end;
end;

See Also

Write