4D Blog

Home Product Links in 4D Write Pro documents

Links in 4D Write Pro documents

April 29, 2019

Product

As a developer or end user, you know how convenient hyperlinks can be. Without them, you would need to know the URL for every page on the internet! They let you turn your text or pictures into links to allow easy transitions from one place (e.g., a 4D Write Pro document) to another (typically a website).

What if links could offer more? What if they could launch the execution of 4D code or simply move the cursor to a different area in the same document? They can!

You can insert links in your documents with the WP Set attribute command, but only URLs. The new WP SET LINK command allows you to set URLs too (easier), but also gives you the ability to invoke a method from your application (with parameters!) or target bookmarks from your document!

FOUR kinds of links

  • The first link types works similar to WP Set attributes ($range;wk link url…) except the parameter is now an object instead of a string.

$link:=New object("url";"www/4d.com")
WP SET LINK($target;$link)

  • The second link type allows creating links that, when clicked, will run a 4D Method. The method can even receive a text or numeric parameter. Just be sure that the method is set as “allowed” with the SET ALLOWED METHODS command.

$link:=New object("method";"myAlert";"parameter";"Hello world!")
WP SET LINK($target;$link)

  • The third link type allows defining links to external documents (on disk). The documents must be 4D Write or 4D Write Pro documents in order to be imported. They will replace the current document.

$link:=New object("url";"HelloWorld.4WP)
WP SET LINK($range;$link)

  • The fourth link type is new: A link can be set to a bookmark. Of course, the bookmark must have already been created in your document. When the link is clicked, the cursor will automatically “jump” to the bookmark!

$link:=New object("bookmark";"chapterOne")
WP SET LINK($target;$link)

Have you noticed that the first parameter is a target? It can be either a range or any other valid object of your document (like a paragraph or any element like a picture). This will make your programming much easier to write and maintain!

Now that links have been set, let’s get them!

As you can guess, the new WP SET LINK command comes with a sibling: WP Get links.

In a single call, this command returns a collection of all the links in a document. Each link of this collection is an object with a description of the link in its attributes.

The attributes are:

link.url (for URL links)
link.bookmark (for bookmark links)
link.method (for method links)
link.parameter (if any)
link.range (information such as.start, .end, etc.)

Below is an HDI to demonstrate all these possibilities :

Database example

More details can be found on the doc center.

Discuss

Tags 4D Write Pro, v17 R5, v18, Word processor

Latest related posts

  • February 3, 2026

    4D Write Pro – Adding a margin automatically when bullets are set using standard actions

  • January 22, 2026

    Transform Static Documents into Actionable Knowledge with AIKit

  • January 22, 2026

    Deploy Fluent UI effortlessly in your 4D applications

Roland Lannuzel
Roland Lannuzel
• Product Owner & 4D Expert • After studying electronics, Roland went into industrial IT as a developer and consultant, building solutions for customers with a variety of databases and technologies. In the late 80’s he fell in love with 4D and has used it in writing business applications that include accounting, billing and email systems.Eventually joining the company in 1997, Roland’s valuable contributions include designing specifications, testing tools, demos as well as training and speaking to the 4D community at many conferences. He continues to actively shape the future of 4D by defining new features and database development tools.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor
Subscribe to 4D Newsletter

© 2026 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy