4D Write Pro is continuously evolving; thanks to the new features and functionalities we’re shipping with every R-release. A world of possibilities is wide open! Today, thanks to a new command, you can get a set of information about the location of any element within your documents.
Here is a database example to get you up and running with this new feature:
4D Write Pro: Get an element position
Five DATA POINTS at once
A new command, dedicated to 4D Write Pro is now available: WP Get position. Given a specific range, element, or reference, this command returns an object variable with five important data points at once: the section number where the range begins, the page number, the column number, the line number, and even the position of the first character of the range in the line!
This feature will allow you to easily generate your documents by programming. For instance, applying complex rules like “Set the fonts of all the paragraphs of page 3 in Arial 18pt” or “Create an index based on the bookmarks on the last page”, can now be done in just a few lines of code. It’s a breeze!
CODE example
Here is a code snippet to set the color of the first and last page of a document to blue (and the rest to black):
$nbPages:=WP Get page count([DOC]Sample)
$body:=WP Get body([DOC]Sample)
$_paragraphs:=WP Get elements($body;wk type paragraph)
For each ($paragraph;$_paragraphs)
$info:=WP Get position($paragraph)
If ($info.page=1) | ($info.page=$nbPages) // First and last page paragraphs in blue
WP SET ATTRIBUTES($paragraph;wk text color;"blue")
Else // Other pages paragraphs in black
WP SET ATTRIBUTES($paragraph;wk text color;"black")
End if
End for each