- Move parts of the long main() function into a new function doformat(). - Rewrite the loop in main() to be more understandable.
- Move parts of the long main() function into a new function doformat().
- Rewrite the loop in main() to be more understandable.

jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase