4D v16

WP CREATE BOOKMARK

Home

 
4D v16
WP CREATE BOOKMARK

WP CREATE BOOKMARK 


 

WP CREATE BOOKMARK ( rangeObj ; bkName ) 
Parameter Type   Description
rangeObj  Object in 4D Write Pro range
bkName  String in Name of bookmark to create

The WP CREATE BOOKMARK command creates a new bookmark named bkName based upon the 4D Write Pro rangeObj in the range's parent document.

Bookmarks are named references to ranges, which allow you to access and reuse specific parts of the document, for example for templating purposes. For more information, please refer to the section.

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 Get selection(*;"WPDocument")
 WP CREATE 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 CREATE BOOKMARK($wpRange;$bookmarkNewName)
 End if



See also 

Download HDI database
WP DELETE BOOKMARK
WP Get bookmark range
WP GET BOOKMARKS

 
PROPERTIES 

Product: 4D
Theme: 4D Write Pro Language

This command can be run in preemptive processes

 
HISTORY 

New
Created: 4D v16

 
ARTICLE USAGE

4D Write Pro Reference ( 4D v16)