This is a question for program design. There are 2 possibilities I see, where I want to know which one is better and why (aspects: readability, performance, expendability, complexity etc.) If you got an other one (sequential only pls no OO stuff xD) feel free to post it and explain its pros and cons
It is a simple report looping over entries from a file, doing something with them and generate a printfile (without a dedicated printer, 3rdparty software, I need to calculate the pages by myself)
Solution NESTED LOOPS in pseudocode
//loop over entries
perform until End-Of-File
perform page-heading
//loop over pages
perform until End-Of-File or End-Of-Page
perform calculate-entry
perform print-entry
end-perform
perform page-footer
end-perform
Solution EVENT in pseudocode
//loop over entries
perform until End-Of-File
evaluate line-counter
case heading-position
perform page-heading
case footer-position
perform reset-line-counter
perform page-footer
case other
perform calculate-entry
perform print-entry
end-evaluate
end-perform
My final program will be in cobol, but I occurred the same question in ABAP so feel free to argument with any sequential language.