Good Afternoon,
I am trying to read an ASCII file which has some non readable characters in it.
I read about 10 lines of the file and then the file status indicates an end of file (hex 10), but there are a number of lines left.
I believe these non readable characters are causing COBOL to think an end of file has been reached, is there anyone around this?
Thanks,
Bob
Hi Bob,
If you are reading an ASCII file defined as organization is line sequential, then it expects that all characters read are printable ASCII characters except X"0D0A" which is used as a record delimiter and X"1A" which can be used as an EOF marker.
Normally if you need to store non-printable characters in an ASCII file you would set the configuration option INSERTNULL=ON which causes a null character to be inserted in front of each non-printable character in the file when doing a WRITE or REWRITE. This null character is then used when reading the file to signal that the next character read should not be interpreted as a control character.
If this file is not being created by COBOL but comes from a 3rd party then there are a couple of options.
If the character that is being treated as a control character is the X"1A", eof character then you could try setting the configuration option LSFILETERM=OFF:
Syntax:
LSFILETERM={ON|OFF}
Parameters:
ON Interpret x"1a" characters as EOF markers.
OFF Ignore EOF characters and continue reading until the physical end of file.
------------------------------------
If the file contains fixed length records then you could define it as organization is sequential instead of line sequential so that it would allow all types of characters. If the file contains X"0D0A" at the end of each record then you would need to add two bytes to the end of the record in order to read it correctly.
If all else fails you could use the byte stream routines such as CBL_OPEN_FILE and CBL_READ_FILE to read the data from the file.
Thanks.
Good Afternoon,
I am trying to read an ASCII file which has some non readable characters in it.
I read about 10 lines of the file and then the file status indicates an end of file (hex 10), but there are a number of lines left.
I believe these non readable characters are causing COBOL to think an end of file has been reached, is there anyone around this?
Thanks,
Bob
Good Morning Chris,
Thanks for the suggestions. The LSFILETERM did not work, so I will try the other two methods that you suggested.
Thanks,
Bob