#Header
See Also
Purpose
To save time in program development and recompilation by designating the initial portion of a program's source code for precompilation.
Syntax
#Header
source code to be precompiled
#EndHeader
What It Does
Most programs are composed of a "static" part that does not usually change and a dynamic part that is recompiled often. Multiple use statements are a common example of the first part of a program, which may be considered static. This static portion of your program is called the "header".
You may define the header of your program and compile that portion only once. The header will be automatically included, precompiled, when you compile the dynamic portion of your program. This technique can significantly reduce the time it takes to recompile a large program.
A header of your program can be designated with the #Header and #EndHeader directives. When you compile a program with these commands using the -P compiler option, only the header will be compiled, and the following files will be produced: progname.FLD, progname.PBG, progname.PDP, progname.PKD, and progname.PRP.
When you compile the program without the -P option, the .FLD, .PBG, .PKD, and .PRP files will be included, and the header will not be recompiled. Only the portion of your program after the #EndHeader will be compiled.
As portions of your program become complete and tested, you may move them into the header and recompile the header. It is your responsibility to ensure that the header is recompiled (with -P) every time you change it.
#Header
use Dfallent.pkg
use vtable.pkg
use mypackage.pkg
#EndHeader
open persons
:
In this example, a program begins with a precompiled portion made up of three use commands. The portion of the program to recompile with every compilation begins with the open command following the #EndHeader directive.
The #EndHeader must be used to terminate the precompiled section. A program may have no more than one #Header... #EndHeader pair.
Notes
- Precompilation can also be accomplished through the use of the Use command, but in that case, the precompiled code must be in a separate file.
- Forward references are allowed from the first program (or header) to the second.
- All symbols, variables, windows, objects, and files are carried forward from the first program to the second, just as if the programs were compiled together.
- The header must compile without errors before it can be used.
- Command blocks and object definitions may not span the
#EndHeaderdirective. In general, anything you begin in the first part must be completed in the first part. - The
.FLD,.PBG,.PDP, and.PKDfiles must be accessible to includeprognameprecompiled. Ifprogname.FLD,progname.PBG,progname.PDP, andprogname.PKDcannot be found, the header will be recompiled, and the#Headerdirective will have no effect. - The
#Headerdirective must be the first line of the program (excluding comments). If you have both a use and#Header, the use command would go after the#Header.