Topic Path: Symbol Reference > Classes > TIdIOHandler Class > TIdIOHandler Methods > Write Method > Write Method (TIdStream, Int64, Boolean)
ContentsIndexHome
PreviousUpNext
TIdIOHandler.Write Method (TIdStream, Int64, Boolean)

Writes content from a stream to the IOHandler.

procedure Write(
    AStream: TIdStream; 
    ASize: Int64 = 0; 
    AWriteByteCount: Boolean = False
); virtual; overload;
Parameters 
Description 
AStream 
Stream with content to write to the IOHandler.
 
ASize 
Number of bytes from the stream to write to the IOHandler. Default value is 0.
 
AWriteByteCount 
Indicates if the bytecount for the operation is written to the IOHandler. Default value is False. 

Write is an overloaded method used to write content from a stream to the IOHandler. 

AStream is a stream instance with the content to write to the IOHandler. 

ASize indicates the number of bytes from the stream to write to the IOHandler. The default value is 0, and signifies that all of the content in the stream as indicated by its' Size should be written. The value -1 indicates that any content in the stream should be written starting at the current stream position, and and include all content up to and including the Size of the stream. When ASize contains a positive non-zero value, the argument value is used as the total number of bytes to write to the IOHandler. 

AWriteByteCount indicates if the byte count for the operation is written to the IOHandler. When AWriteByteCount contains True, the value in ASize is written as the initial step in the write operation. ASize will be written as an Int64 data type when LargeStream contains True. ASize will be written as an Integer data type when LargeStream contains False. The default value for AWriteByteCount is False. 

Write can raise an EIdIoHandlerRequiresLargeStream exception if ASize is larger than the value MaxInt when LargeStream contains False. What does this really mean? It means that older VCL versions that do not support 64-bit stream sizes and positions should not call Write using a byte count value in ASize larger than the value MaxInt. 

Write signals the OnWorkBegin, OnWork, and OnWorkEnd event handlers when writing values using the IOHandler. The expected number of bytes in ASize is passed to the OnWorkBegin event handler. The OnWork event handler is signalled when byte values are output using the IOHandler. The OnWorkEnd event handler is signalled just prior to completion of the method. 

Write iteratively sends blocks of data from the stream in AStream until the requested number of bytes have been read from the stream and written to the IOHandler. The value in the SendBufferSize property indicates the number of bytes read from the stream and written to the IOHandler during each iteration of the processing required in the method. 

Write can raise an EIdNoDataToRead exception when the required number of bytes in ASize cannot be read from the stream.

Exceptions 
Description 
Raised when the requested number of bytes is larger than the maximum value supported for the stream.
 
Raised with the message RSIdNoDataToRead when a required number of bytes cannot be read from the stream. 
Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.