Back to DFS's Pascal Page


Needle in a File Haystack Problem II

Earlier you wrote a program which found all occurrences of a needle in a haystack which saved in a disk file. You then listed the line and character positions where the user-specified needle is found.

In this program, you will also find all occurrences of the needle in the haystack. However, instead of listing its positions, you will color each occurrence.

You will use the text of O Canada to develop your program. It should produce output such as the following.

Pseudocode

The structure of your program should be very simple.

  1. Setup
  2. Load file
  3. Find longest line and print numbered lines
  4. Number the character positions of the line
  5. Get the needle substring from the user
  6. Introduce results
  7. Highlight the occurrences of the needle in the text

© DFStermole 2008
Created 30 Mar 08
Modified 30 Mar 08