procedure GetBlock(var Block; Len : Word);
Returns a block of received characters and removes them from the dispatcher buffer.
This routine makes a request to return the next Len received bytes. The data is moved into the buffer referenced by Block. A memory overwrite will result if Block is not large enough to hold Len bytes. If fewer than Len bytes are available, none are returned and an EBufferIsEmpty exception is generated. The returned bytes are removed from the Async Professional CLX dispatcher buffer.
To determine if line errors occurred while the communications driver was receiving this data, check the LineError property after calling GetBlock.
The following example calls GetBlock to remove the next 128 bytes from the dispatcher buffer, and handles the various possible outcomes:
var
Block : array[0..127] of Char;
...
try
ApxComPort.GetBlock(Block, 128);
except
on E : EAPXException do
if E is EBufferIsEmpty then begin
...protocol error, 128 bytes expected
raise;
end;
end;
See also: CharReady, GetChar, InBuffUsed, PeekBlock