SPLat/PC: The preprocessor
Since Build 163 SPLat/PC has contained a preprocessor. The preprocessor allows special code lines that result in significant transformation of the program prior to the actual translation process. The preprocessor is capable of things such as:
- Conditional translation (compilation) using
#IF, #ELSE, #ELSEIFand#ENDIF.More… - Including other files, to simplify libraries (re-usable code)
- Automatic code generation for predetermined functions, such as thermistor calculations.
- Moving all
mEQUlines to the front of the final file, and all NVEM page 0 data directives to the end
As an example, the preprocessor is what allowed us to make programming for SimpleHMI extremely simple. The preprocessor takes so-called hash commands and hash functions and converts them into regular SPLat code plus NVEM0 tables.
Using the preprocessor
Whenever you translate a program the preprocessor is used to process your program file before the translator itself kicks in. If you are happy to translate and immediately run your program in a SPLat board, without using the simulator (single stepping etc), then there is nothing more to do.
However, the simulator inside SPLat/PC is cannot handle hash commands like #HMI, #Include or #IF. Therefore if you want to step your program you can use the menu item File>Pre-process. This will run the preprocessor and produce a new read-only file in a new editor window. That file has all the hash commands etc expanded into regular SPLat code, and can be run or single stepped in the simulator.
The best way to learn to understand the preprocessor is to copy a few of the code examples from the Hash commands and functions section of the programming reference and see what the File>Pre-process command does to them.