Information Technology Reference
In-Depth Information
write newfile
if new-status > 0
error-msg = “problem writing the file; program aborting - press enter”
go to end-program
end-if
which will take the sorted array and write it out to a new file,
newfile
one record at a time. This process can be described as a sequential write, since one record
after another is being written to the output file. It's a bit different from our earlier writes.
The perform is done by varying
i-sub
from 1 by 1 until it is equal to
record-count .
Thus
i-sub
will start out as 1 and the first element of the table will be written to the file. This process
will continue until all the records are written to the file. Thus the loop will continue and if
record-count
were 8, the paragraph would been completed for
i-sub
equal to 8 and that would end the
perform
since
i-sub
would equal
record-count .
There is one note of caution that I must add. Some systems would not write out
the last record using our specific logic. We would have to say
perform write-file varying i-sub from 1 by 1 until i-sub > record-count
in the perform statement. That depends on when the variable
i-sub
is checked against
record-count .
In our system it is done after the last line of the paragraph and so we did write out the last
record. However, other systems might check before the paragraph starts. You can see that
if that is the case, the very last record would not be written since the comparison of
i-sub
to
record-count
would result in an equal condition and the perform would be done without writing out the
last record. This is a small point but something that you have to consider. If you write out
records to a file and somehow the last record is missing, this could be your problem.
If there is a problem with the
Search WWH ::




Custom Search