WP Get breaks
WP Get breaks ( targetObj {; breakType} ) -> Function result
Parameter | Type | Description | |
---|---|---|---|
targetObj | Object | → | Range or element or 4D Write Pro document |
breakType | Longint | → | Type of breaks to return |
Function result | Collection | ← | Collection of ranges |
Description
The WP Get breaks command returns the collection of all breaks inserted in targetObj.
This command only returns breaks entered by a user or the code, and not those automatically generated by 4D Write Pro for layout purposes.
In the targetObj parameter, you can pass:
- a range, or
- an element (table / row / paragraph / body / header / footer / section / subsection / text box), or
- a 4D Write Pro document
By default, breaks of any type are returned. You can select a specific break type to return by passing one of the following constants in the optional breakType parameter:
Constant | Value | Comment |
---|---|---|
wk column break | 3 | Column break: inserts a column break |
wk continuous section break | 5 | Defines a continuous section break (often used to change the number of columns without starting a new page). |
wk line break | 0 | Line break (in the same paragraph) |
wk page break | 2 | Page break: defines a new page |
wk paragraph break | 4 | Paragraph break: defines a new paragraph |
wk section break | 1 | Section break: defines a new section |
Returned value
WP Get breaks returns a collection of range objects, each of them describing a break within the targetObj. A specific read-only property is available in each range object, providing the type of the break:
Property | Type | Constant | Description |
---|---|---|---|
[ ].breakType | Number | wk break type | Read-only: type of the break |
If targetObj is a range or element, breaks are returned in the order they are found.
If targetObj is a 4D Write Pro document, breaks are returned in the following order:
- body
- first page header for section 1 (if any)
- first page footer for section 1 (if any)
- left page header for section 1 (if any)
- left page footer for section 1 (if any)
- right page header for section (if any)
- right page footer for section 1 (if any)
- main header for section 1 (if any)
- main footer for section 1 (if any)
- repeat with section 2, section 3, and so on
- text boxes.
An empty collection is returned if targetObj does not contain any break (or any break of the requested breakType).
Example
You want to replace all line breaks with paragraph breaks in the document:
var $_filteredBreaks : Collection
var $break : Object
$_filteredBreaks:=WP Get breaks(WParea;wk line break)
For each($break;$_filteredBreaks)
WP INSERT BREAK($break;wk paragraph break;wk replace)
End for each