Skip to main content
Version: Next

Ranges

4D Write Pro allows you to programmatically select and manipulate document contents. Since the selected content can include text, images, tables, etc., and also (invisible) formatting tags, 4D Write Pro works with objects called ranges.

A range is an object that represents a portion of a 4D Write Pro document:

  • a range of characters, paragraphs, pictures, or tables is defined through character positions within the parent document,
  • a range of cells, columns and rows is defined through cell positions and are anchored to the parent table.

A range is used to designate elements to be selected or manipulate attributes on a part of the document (using WP GET ATTRIBUTES and WP SET ATTRIBUTES).

There are different types of ranges. You can determine the type of a range using the wk type attribute (read-only). Each range contains several private attributes that define it:

ConstantValueComment
wk endend(Read-only attribute)
Range end offset, or section/subsection text end index in the document body (for subsection, text end index of the parent section).
Value type: Longint
wk ownerowner(Read-only attribute)
Owner of the range/object/section/subsection (reference to the document for section/subsection).
Value type: Object
wk startstart(Read-only attribute)
Range start offset, or section/subsection text start index in the document body (for subsection, text start index of the parent section).
Value type: Longint
wk typetype(Read-only attribute) Type of 4D Write Pro object. Possible values:
- wk type default: Range or section with not defined type
- wk type paragraph: Paragraph type range
- wk type image: Image (anchored and inline)
- wk type container: Header or footer, for instance
- wk type table: Table reference
For ranges of cells, columns and rows only:
- wk type table row: Table row reference
- wk type table cell: Table cell reference
- wk type table column: Table column reference
For subsections only:
- wk first page: First page subsection
- wk right page: Right page subsection
- wk left page: Left page subsection

The ranges of rows, columns and cells of tables have specific, private attributes allowing to define them:

ConstantValueComment
wk cell countcellCountTotal number of cells in the row.
Value type: Longint (value for wk type table row)
wk column countcolumnCount(Available for tables, documents and sections) Number of columns.
Value type: Longint
For a table: read-only attribute
For a document or a section: read-write attribute. Default value = 1 (single column). Maximum value = 20
wk first columnfirstColumn(Read-only attribute) Number of the first table column included in the range.
Value type: Longint
wk first rowfirstRow(Read-only attribute) Number of the first table row included in the range.
Value type: Longint
wk header row countheaderRowCount(Read/Write) Number of rows of the table with the attribute wk header set to True.
Maximum value is 5. If you pass a value above 5, wk header is set to True for the first five rows only (see Repeated headers).
wk row countrowCount(Read-only attribute) Total number of rows.
Value type: Longint
wk tabletable(Read-only attribute) The parent table.
Value type: Object
wk table IDtableID(Read-only attribute) ID of the parent table.
Value type: String

Several commands allow you to define document ranges:

You can get information about the position of a range in a document (page number, column number...) using the WP Get position command.