On Mon, 8 Sep 2014 14:31:05 -0500, John McKown <[email protected]> wrote: > >Sure that can happen. No, it is not a problem. Why? Because if the >variable "data" ends with a x'0d', the code will NOT split it. If will >be in the "left over" portion of data. And the line: data=data||record >will put the contents of the _next_ record immediately _after_ any >"left overs". Which will be what is wanted because the x'25' which >starts the next record will then be right after the x'oD' left over at >the end of "data". And the next go though of the DO WHILE will then >use that to split the data. It's hard to show, but assume that ^ >stands for x'0D' and ~ stands for x'25'. Suppose the data in the file >looks like: > >abc^~def^ >~ghi^~qr^b^~ > >The code will read abc^~def^ into record. Concatenate to data, which >is initially ''. So this results in output being abc (and written out) >and data being def^. It reads again & concatenates. result is >def^~ghi^qr~b , DO WHILE will split this into def and ghi^~qr~b, >output def, then loop. 2nd time through, split is ghi and qr~b. Output >ghi. data now qr^br^~ which has a ^~ and so loop 3rd time, output >qr^b, leaving data ''. No ^` in data, so exit DO WHILE. continue DO >FOREVER. EXECIO failes because of EOF, so exit DO FOREVER. execute >second DO WHILE but nothing output because data is still ''. Hum, the >code does have a bug. If the data in the input file does not exit with >x'0D25', the last record will not be written. > Thanks for the detailed explanation with example.
Bill ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
