(This example was inspired by the bookThe Pragmatic Programmer by Andrew Hunt and David Thomas.) Most software allows the user to enter parameters to configure the software's behaviour. These parameters often have a default value. For example, the programxbiff (which informs users when new mail arrives) has an update rate which tellsxbiff how often it should check for new mail. The user can specify a value for this option when starting the program. If no value is specified a default is used. The default value will be documented somewhere, normally in a man page and possibly in any other documentation which comes with the program. If the developer changes the default value in the code, they must also remember to change the value wherever it appears in the documentation.filepp can be used to automate these changes. When setting default values in a C program, it is normal to#define them, as the value may be needed in more than one place. For example:xbiff's update rate may be needed in the piece of code that does the actual updating and in the command line help. Asfilepp understands the#define keyword, it can also read the include file containing the default value. The include file could appear something like this: This file can be included in all C and C++ files wherever it is needed. It can also be used in any ASCII documentation (man page, HTML, LaTeX, etc.) and pre-processed byfilepp provided care is taken over the handling of the comments. For example, in a HTML file the include file could be embedded in a HTML comment, eg: This allowsfilepp to parse the include file, but as the contents of the include file are hidden in a HTML comment they will not appear in the actual web page produced. However, asfilepp has parsed the#define line, it will replace all occurrences of the macroUPDATE_RATE with the definition30. A different way of hiding the C comments is to usefilepp to convert them into the file's native comment style. For example, all LaTeX comments start with the character%. So for the above example, iffilepp is run with the following command line: - filepp -D"/*=%" -D"//=%" userguide.tex.in -o userguide.tex
it will convert all C and C++ comments of the form "/*" and "//" to LaTeX comments: "%". |