4D Write Pro: More simple, more powerful

Automatically translated from English

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

$range:=WP Create range(WParea;wk start text;wk start text)  //create a range on start
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)   // Add text before the existing text
WP INSERT BREAK(WParea;wk paragraph break;wk append)  // append a paragraph break
WP INSERT PICTURE(WParea;$pict;wk append)     // and a picture at the end of my document

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.

 

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.