unreadblock

The unreadblock function provides a method of moving the input file-pointer back one block (a block of data is equivalent to one EDI segment or one positional record). This function “unreads” the block of data that was just processed by the readblock function.

Note: The unreadblock function works only once and only for the most recent readblock. If you use unreadblock more than once, you will not be able to point to any earlier readblocks.

Unreadblock must only be used in conjunction with the readblock function.

The unreadblock function is commonly used with the readblock and writeblock functions to pass blocks of data in bulk from the input file to the output file. This is useful for maps that are designed to envelope data.

Unreadblock enables the translator to correctly track the number of bytes read and number of segments read during the translation process by moving the file-pointer back and decrementing the segment and byte counts accordingly.

Readblock, writeblock, and unreadblock are supported only for positional and EDI files, and are not supported for XML files.

Syntax

Use this syntax:



unreadblock();

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.