4D Blog

Home Product 4D Write Pro: More simple, more powerful

4D Write Pro: More simple, more powerful

May 29, 2019

Product

A shout out to everyone using 4D Write Pro and letting us know your thoughts about the product. This lets us better understand your needs and difficulties. Thanks to this input, we’ve realized that some commands have become unnecessary, complex to use, and/or difficult to learn. Sometimes it could be the smallest things that make learning a challenge. For example, if you just want to insert some text in the footer, you first need to create an empty range! Why so complicated? Good question!

Thus, many commands that previously only used ranges have been extended in order to manage almost any kind of target (ranges, elements, sections, documents, etc.). Code is now easier to write and read. If you need to insert text … in a document, a footer, a range, (wherever!) …  just use it as the target and you’re off and running.

And that’s not all! Six commands have been renamed with shorter names, so they’re easier to remember.

HDI: 4D Write Pro – more targets and renamed commands 

More targets…

The commands listed below have been extended to accept any kind of target as first parameter. This means they can still use a range, but now they can also use a reference (header, body, footer), an element (picture, paragraph) or even the entire document as target!

  • WP SET TEXT
  • WP INSERT BREAK
  • WP INSERT DOCUMENT
  • WP INSERT PICTURE
  • WP Insert table
  • WP SET ATTRIBUTES
  • WP GET ATTRIBUTES

 

Let’s look at an example: I want to insert text at the beginning of my document and a picture at the very end of it, how should I do that?

Previously, you needed to get two ranges, one at the beginning and one at the end of the document. Then you had to insert the text for the first range, add another range and extend it with a paragraph break, and finally insert the picture.

Previous code

// Create a range on start
$range:=WP Create range(WParea;wk start text;wk start text)
WP SET TEXT($range;"Hello world!";wk prepend)
$range:=WP Create range(WParea;wk end text;wk end text)
WP INSERT BREAK($range;wk paragraph break;wk append;wk include in range)
WP INSERT PICTURE($range;$pict;wk append)

New code

WP SET TEXT(WParea;"Hello world!";wk prepend)
WP INSERT BREAK(WParea;wk paragraph break;wk append)
WP INSERT PICTURE(WParea;$pict;wk append)

Renamed commands

The commands listed below have been renamed. No more Get or Create, the important thing to remember is range!

Previous name New name
WP Create Paragraph range WP Paragraph range
WP Create Picture range WP Picture range
WP Create range WP Text range
WP Create Table range WP Table range
WP Get bookmark range WP Bookmark range
WP Get selection WP Selection range

Examples

Here are some examples to get different kinds of ranges:

// get the range of the paragraphs of the document
$paragraphRange:=WP Paragraph range(WParea)

// get the range of pictures inside the document
$pictureRange:=WP Picture range(WParea) 

// get the range of a part of text from the document
$textRange:=WP Text range(WParea;10;20)

// get the range of the tables of the first section of the documents
$tableRange:=WP Table range(WParea;WP Get section(WParea;1))

// get the range of a specific bookmark
$bookmarkRange:=WP Bookmark range(WParea;"MainPart")

// get the range of the user selection
$selectionRange:=WP Selection range(WParea)

 

The documentation for these commands has been updated and the HDI above demonstrates all the new abilities.

 

Discuss

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

Latest related posts

  • July 18, 2025

    Embed deployment license automatically into your applications

  • July 17, 2025

    New Class to Perform UDP Communications

  • July 17, 2025

    Managing Calendar Events with Microsoft 365 or Google in 4D: Create, Update, Delete

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

  • 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-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R9 20 R10 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R9 20 R10 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 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