Since v16 R5, it’s been possible to access and modify an existing header and footer by programming. If you want to add a header and footer to your 4D Write Pro document, you use a template to do so!
If you’re not a fan of templates, good news! With 4D v17 R3, you can create a header and a footer by programming for a given section.
Two new commands are at your disposal for this purpose: WP New header and WP New footer.
Of course, you can also delete a header and a footer by programming with the WP DELETE HEADER and WP DELETE FOOTER commands.
For example, the following code adds a header and a footer in the current section:
// Retrieve the current section
$section:=WP Get section($range)
// Create a header
$header:=WP New header($section)
// Create a footer
$footer:=WP New footer($section)
Then you can insert your text in the header and format it as follows:
// Create a new range containing only the header
$headerRange:=WP Create range($header;wk end text;wk end text)
// Insert text
WP SET TEXT($headerRange;"Hello World!";wk append)
// Set in bold
WP SET ATTRIBUTES($header;wk font bold;wk true)