4D v17Accessing document contents by programming |
|||||||||||||||||||||||||||||||||||
|
4D v17
Accessing document contents by programming
|
Constant | Value | Comment |
wk end | end | (Read-only attribute)
Value type: Longint |
wk owner | owner | (Read-only attribute) Owner of the range/object/section/subsection (reference to the document for section/subsection). Value type: Object |
wk start | start | (Read-only attribute)
Value type: Longint |
wk type | type | (Read-only attribute) Type of 4D Write Pro object. Possible values:
For ranges of cells, columns and rows only:
For subsections only:
|
Note: Ranges of cells, columns and rows contain specific attributes (see paragraph below).
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.
4D Write Pro tables are created and built programmatically by using the following commands:
(*) Columns have no equivalent in html. In 4D Write Pro, a column range is actually a range of cells.
The ranges of rows, columns and cells have specific, private attributes allowing to define them:
Constant | Value | Comment |
wk column count | columnCount | (Available for tables, documents and sections) Number of columns. Value type: Longint
|
wk first column | firstColumn | (Read-only attribute) Number of the first table column included in the range. Value type: Longint |
wk first row | firstRow | (Read-only attribute) Number of the first table row included in the range. Value type: Longint |
wk row count | rowCount | (Read-only attribute) Total number of rows. Value type: Longint |
wk table ID | tableID | (Read-only attribute) ID of the parent table. Value type: String |
4D Write Pro allows you to create and work with dynamic references to parts of your documents, called bookmarks. A bookmark is a named reference attached to a specific range in a 4D Write Pro document.
Bookmarks are dynamic, which means that if the user moves, adds or removes text belonging to the bookmark, the associated range will be updated automatically and the bookmark will continue to reference the same content within the document. For example:
A document can contain an unlimited number of bookmarks. Several bookmarks can reference the same range, and bookmark ranges can be interleaved. However, each bookmark name must be unique in the document. Bookmarks are not imported when using the WP INSERT DOCUMENT command (bookmarks in the destination document cannot be overwritten).
Once created, a bookmark is stored within the document. It is saved with the document, and can be handled by several different commands. It can also be used to reference parts of a template document. These parts can then be assembled automatically with data from the database to produce dynamic output documents such as invoices or catalogs.
Several commands allow you to create, remove, and use bookmarks:
The following commands can get or set any attributes of the document:
Attributes are detailed in the 4D Write Pro Attributes section.
This command allows you to get information about style support for a range:
4D Write Pro allows you to assign hyperlinks to any range of your document, including ranges of text, paragraph, picture, table rows, or cells. For example, you can set a hyperlink to a picture range; once the 4D Write Pro document is exported to HTML, users can click the picture to open a page at a specified address.
Note: Hyperlinks can be activated from within 4D Write Pro documents using the Ctrl+click (Windows) or Cmd+click (macOS) shortcut.
Hyperlinks are handled as range attributes, and are set or get using the WP SET ATTRIBUTES and WP RESET ATTRIBUTES commands along with the wk link url constant. For example, if you want to transform the text selected by the user to an URL:
You can write:
$range:=WP Get selection(*;"WParea")
WP SET ATTRIBUTES($range;wk link url;"http://doc.4d.com")
Note: 4D Write Pro does not translate the URL's special characters, if any. You need to encode special characters if necessary. If the URL is not valid, an error is generated.
Inserted URLs get the default hyperlink format (underline blue color), unless a text style is already applied to the range.
When handling URLs in your documents, 4D Write Pro applies the following rules:
WP RESET ATTRIBUTES($range;wk link url)
WP SET ATTRIBUTES($range;wk link url;"")
Product: 4D
Theme: 4D Write Pro Language
Modified: 4D v16
Modified: 4D v16 R4
Modified: 4D v16 R5
4D Write Pro Reference ( 4D v17)