4D Write Pro documents support five types of breaks:
- line breaks
- paragraph breaks
- page breaks
- section breaks
- column breaks
Sometimes, you need to locate a certain type of break to replace it with another, or simply delete all its occurrences in the document. To make this possible, we developed a new function: WP Get breaks.
New command
WP Get breaks returns by default all five types of breaks. These are explicit breaks, meaning breaks that have been intentionally entered by the user, either on their keyboard or from a menu or context menu.
The other breaks, caused by the page layout, for example, are not taken into account because they’ve been inserted implicitly, for display or printing purposes. They are not part of the document.
This command can also, on-demand, return only a given type of break, such as page breaks for instance.
The result is very easy to use because this new command returns a collection of ranges that are directly usable by other commands that take this type of argument as a parameter.
Some examples
Thanks to this command, it’s now easier to replace section breaks with simple page breaks.
It’s also possible to locate multiple paragraph breaks. You can therefore delete duplicates or replace all of them with page breaks, replace column breaks with paragraph breaks, and so on.
Code Sample
The sample code below replaces all the line breaks with paragraph breaks:
// Find all the line breaks
$_filteredBreaks:=WP Get breaks(WParea; wk line break)
// Replace them with paragraph breaks
For each ($break; $_filteredBreaks)
WP INSERT BREAK($break; wk paragraph break; wk replace)
End for each
Easy, right?
Next STEPS
You’ll find everything you need to know in the documentation. And as always, for all kinds of questions or feedback, feel free to join us on the 4D forum.