Problem:
The following code causes the second print line to overlay the first:
select pfile assign printer
organization line sequential.
fd pfile.
01 pf-record pic x(60).
working-storage section.
01 report-line1 pic x(60) value
"Report Line 1".
01 report-line2 pic x(60) value
"Report Line 2".
01 report-line3 pic x(60) value
"Report Line 3".
procedure division.
open output pfile.
write pf-record from report-line1 after 3.
write pf-record from report-line2.
write pf-record from report-line3.
close pfile.
stop run.
when executed the second line "Report Line 2" overwrites "Report Line 1". Looking at the hex it is easy to see why this happens:
0A 0A 0A Report Line 1 0D
Report Line 2 0D 0A
Report Line 3 0D 0A
Can this be fixed?
Resolution:
The results being seen are correct (although undesired) given the above example. The Net Express documentation states:
If the ADVANCING phrase is not used, automatic advancing of one line is provided to act in
accordance with the convention of your operating system text editor (usually as if you had
specified BEFORE ADVANCING 1 LINE).
To work around this behaviour there are two options:
1) Code the AFTER 1 clause on each WRITE.
2) Set WRITELINE=OFF in the EXTFH.CFG file to ensure that unqualified WRITE statements write
as write after advancing 1.