13.6 Using a Pascal preprocessor

Sometimes you want to use symbolic names in your resource file, and use the same names in your program to access the resources. To accomplish this, there exists a preprocessor for windres that understands pascal syntax: fprcp. This preprocessor is shipped with the Free Pascal distribution.

The idea is that the preprocessor reads a pascal unit that has some symbolic constants defined in it, and replaces symbolic names in the resource file by the values of the constants in the unit:

As an example: consider the following unit:

unit myunit;  
  First  = 1;  
  Second = 2:  
  Third  = 3;  

And the following resource file:

#include "myunit.pp"  
STRINGTABLE { First, "hello World !"  
              Second, "hello world again !"  
              Third, "last hello world !" }  

If you invoke windres with the preprocessor option:

windres --preprocessor fprcp -i myunit.rc -o myunit.res

then the preprocessor will replace the symbolic names ’first’, ’second’ and ’third’ with their actual values.

In your program, you can then refer to the strings by their symbolic names (the constants) instead of using a numeric index.