[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Embedded Nulls



Jay,

> I'm reading fixed length records from a flat text file.  Some records have
> an embedded null character in the middle of the record and when I use the
> "substr" function to extract data beyond this point, nothing is returned.
> I'm assuming SQR is treating the null as a line terminator.
>
> Has anyone ever encountered this and found a work around (I can't control
> the source of the input file)

Open the file as FIXED or FIXED_NOLF instead of VARY.  Then, when
reading the file, don't read it all into one big string and
then try to parse it.  Instead, use something like this:

READ 1 INTO $field_1:30 $field_2:24 #possibly_nul:1 $field_4:32

In this case I'm specifying the exact field lengths for each
part of the input line, and I'm using numeric variables to read
binary (non-string) data.

Ray
----------------------------------------------------------------------
Ray Ontko   rayo@ontko.com   Phone 1.765.935.4283   Fax 1.765.962.9788
Ray Ontko & Co.   Software Consulting Services   http://www.ontko.com/