4D Write Pro: a new way to set TABS!

We’re thrilled to announce an exciting enhancement in 4D Write Pro! In addition to the features we’ve rolled out so far, 4D v17 R5 also includes a new feature for tabs.

Thanks to the horizontal ruler, setting tabs has become an easy task for the users. They can define the offsets, types, and even the leading character of each tab graphically, simply by using their mouse. But when the same task is performed by a developer via programming, it wasn’t as easy as expected. Three arrays had to be used, one for each kind of setting. Well, not anymore! Now things are much more simple: setting tabs can be done using a collection of strings, numeric values, or even a collection of objects! And that’s not all! If you only need to modify the default tab values, you can use an object with the new constants (added specially for this purpose).

HDI: 4D Write Pro – A new way to set tabs 

default tab settings

A tab is defined by three values: offset, type, and leading character. These three values have their own default values:

  • Offset default value = 1.25cm
  • Type default value = left
  • Leading char default value =  ” ” (none = empty string)


Therefore if you want to modify the default offset value, you can simply execute this single line of code:

WP SET ATTRIBUTES(WParea;wk tab default;2) // in this case, 2 is two of the current unit (e.g., cm)


// In this case, "1.5cm" is a CSS string that will be used (always a dot - not a comma - with no space)
WP SET ATTRIBUTES(WParea;wk tab default;"1.5cm") 

And if you also want to modify the type of the tab, then you can create an object with three attributes and send it to the same function.

$tab:=New object
$tab[wk type]:=wk left
$tab[wk offset]:="3cm"
$tab[wk leading]:="."
WP SET ATTRIBUTES($body;wk tab default;$tab)

Note: $tab.type is equivalent to $tab[wk type]. The difference is that you can use constants with bracket notation (not possible with dot notation), which helps avoid typos.

MORE tab settings

For compatibility reasons, using arrays is still possible, but it’s much easier to use collections. It’s your call!
Defining tabs is as easy as describing them: “I want three tabs. The first at 2 cm, the second at 8 cm, and the last at 13 cm. Ok, let’s do this:

WP SET ATTRIBUTES(WParea;wk tabs;New collection("2cm";"8cm";"13cm"))


Wait … why do I need to specify the “cm” if it’s my document’s unit ?
Well actually, you don’t! You can also use numerical values in your collection and the current unit will be used:

WP SET ATTRIBUTES(WParea;wk tabs;New collection(2;8;13)

How cool is that?

Now I want my last tab to be decimal and use a hash (aka pound sign, number sign) as the leading character.
In this case, you just need to create an object for your third tab:

$tab:=New object
$tab[wk offset]:=13
$tab[wk type]:=wk decimal
$tab[wk leading]:="#"
WP SET ATTRIBUTES(WParea;wk tabs;New collection("2cm";"8cm";$tab))

Check out the HDI to discover the new possibilities and for in-depth details, take a look at the 4D doc center


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.