This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20 R7
WP NEW BOOKMARK
|
WP NEW BOOKMARK ( targetObj ; bkName ) | ||||||||
Parameter | Type | Description | ||||||
targetObj | Object |
![]() |
Range or element | |||||
bkName | String |
![]() |
Name of bookmark to create | |||||
The WP NEW BOOKMARK command creates a new bookmark named bkName based upon the 4D Write Pro targetObj in the parent document.
Bookmarks are named references to ranges or elements, which allow you to access and reuse specific parts of the document, for example for templating purposes. For more information, please refer to the Bookmark commands section.
In targetObj, you can pass:
Note: If you passed an element in targetObj, the bookmark will contain only the specified element.
In bkName, pass the name for the new bookmark. A bookmark name must be compliant with HTML/CSS names, i.e. it must only contain alphanumeric characters (invalid characters, such as space characters, are automatically removed). Bookmark names must be unique within the document. If a bookmark with the same name already exists in the document, it is overwritten.
You can create as many bookmarks as you want within the same document. Multiple bookmarks can be created using the exact same range. Once created, a bookmark is automatically stored in the parent document and is saved with the document itself.
You want to create a new bookmark referencing the currently selected text in the document. You can write:
C_OBJECT($range)
$range:=WP Selection range(*;"WPDocument")
WP NEW BOOKMARK($range;"my_bookmark")
You want to rename an existing bookmark. To do this, you need to create a new bookmark with the same range, and then delete the old one:
C_TEXT($bookmarkOldName)
C_TEXT($bookmarkNewName)
C_LONGINT($p)
C_OBJECT($wpRange)
$bookmarkOldName:="MyBookmark"
$bookmarkNewName:="MyNewBookmark"
ARRAY TEXT($_bookmarks;0)
WP GET BOOKMARKS(WParea;$_bookmarks)
$p:=Find in array($_bookmarks;$bookmarkOldName)
If($p>0)
$wpRange:=WP Get bookmark range(WParea;$bookmarkOldName)
WP DELETE BOOKMARK(WParea;$bookmarkOldName)
WP NEW BOOKMARK($wpRange;$bookmarkNewName)
End if
Download HDI database
WP Bookmark range
WP DELETE BOOKMARK
WP GET BOOKMARKS
Product: 4D
Theme: 4D Write Pro Language
Number:
1415
Created: 4D v16
4D Write Pro Reference ( 4D v20 R7)