readbytes
The readbytes function reads a number of bytes from the input file. This function is used in conjunction with the writebytes function. Used together, the readbytes and writebytes function provide an efficient method of passing data through a map if the data does not need to be compliance checked or altered in any way.
Readbytes is similar to the readblock function, but readblock only works with entire blocks (for example, an entire segment or record), and readbytes works with any quantity of data, whether it is smaller or larger than a block.
The readbytes function uses two parameters, first the string variable into which the data being read will be stored, and second the number of bytes to read.
Syntax
readbytes(read_from_buffer, num_bytes);where:
read_from_buffer= string variable into which the data being read will be storednum_bytes= integer value representing the number of bytes to read from the input file.
Note: The readbytes function returns the number of bytes it was
actually able to read.
Example
string [1024] tempBuffer;
while readbytes(tempBuffer,1024) do
begin writebytes(tempBuffer,1024);
End
//Read 1024 bytes from input file and place in string variable
//named tempBuffer.
writebytes("^0D^0A",2);
//Appends a CRLF to the end of the output file.