readblock
The readblock function reads a block of data (segment or record) from the input file and places it into the argument of a string variable. The readblock and writeblock functions are used in conjunction with each other to pass a block of data from the input file to the output file without compliance checking or testing for proper EDI syntax. Together, these functions provide a more efficient alternative of using wildcard segments, which are typically implemented in build and break maps.
Readblock, writeblock, and unreadblock are supported only for positional and EDI files, and are not supported for XML files.
Syntax
Use this syntax:
readblock(string_variable);
Example
An example of this function follows:
while readblock(temp_buffer) do
begin
if left(tem_buffer,3) = "IEA" then
begin
unreadblock();
break;
end
writeblock(temp_buffer);
end
//Read record from input file and place in temp_buffer. Look for
//"IEA" record tag. If found, reset file pointer to where it was
//before the "IEA" record was read. Write contents of temp_buffer to
//output file.
The readblock and writeblock functions are also used in conjunction with the Document Extraction service, to specify the beginning and end of each document in a batch of documents, so that each document can be extracted individually.
For more information about using the corollary Update standard rule to complete the document extraction, see Set an Update Standard Rule as Part of Document Extraction.
Example
An example of this function follows:
string[250] buffer;
string[3] match;
integer match_len;
integer eofInput;
// set these next two variables
match = "SUM"; // the tag of the last record in the document
match_len = 3; // the length of the tag
// read the block we're on and write it
readblock(buffer);
writeblock(buffer);
eofInput = eof(0); // check if we are at the end of the input document
// keep reading and writing records until the end of the document
while !eofInput do
begin
if readblock(buffer) then
begin
writeblock(buffer);
if left(buffer, match_len) = match then
//write the document, not new lines and continues to process documents
begin
break;
end
end
eofInput = eof(0);
//set the value of eofInput to 0 because the end of file has been reached
end