Text File Processing

Text files are files that make sense when they are opened with a text editor. Program source files, .html, .rtf (rich text format) and .csv (comma separated value) files are examples. Characters in text files are arranged in lines. In the programs in this section we use the readln procedure to assign a line of text to a string variable. We process this line before reading the next line and continue until the end of the file is reached. We do not need to know the number of lines in the file.

Program DisplayCSV reads a CSV file and formats the output to the screen in different ways.

Program SyntaxHighlight adds some syntax highlighting to a Pascal program in an HTML file.

Program CountWords outputs each word in a text file together with the number of occurrences of that word in the file.

Program ProgStats outputs, for a Pascal source file, statistics such as the numbers of procedures and functions used in the source code.

Follow the links below for these demonstration programs.

Programming - a skill for life!

Character coding schemes, string routines and text file processing