writebytes

The writebytes function writes a specified number of bytes to the output file. This function is used in conjunction with the readbytes 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.

Note: The system does not append a segment terminator to the end of the string value written to the output file.

Writebytes is similar to the writeblock function, but writeblock only works with entire blocks (for example, an entire segment or record), and writebytes works with any quantity of data, whether it is smaller or larger than a block.

The writebytes function uses two parameters, first the string variable containing the data to be written to the output file, and second the number of bytes to write.

Syntax

writebytes(write_to_buffer, num_bytes);

where:

  • write_to_buffer = string variable containing the data to be written to the output file
  • num_bytes = integer value representing the number of bytes to read from the write_to_buffer variable and write to the output file
Note: If hex values are used in constants, use \0x instead of ^.

Example

string [1024] temp_buffer;
while readbytes(temp_buffer,1024) do
begin
	writebytes(temp_buffer,1024);
End
writebytes("^0D^0A",2);

//Read 1024 bytes from input file and place in string variable Snamed temp_buffer.
//Appends a CRLF after the while loop finishes executing.