4D Write Pro: Decimal point or comma for number alignment?

Automatically translated from English

Numbers … big, small, very big, very small …  No matter their size, it’s always better if they’re easy to read. In most countries and languages, separator characters are usually used to separate thousands (or tens of thousands) and there is always a character to distinguish the decimal part from the rest of the number. When it’s time to align these numbers correctly in documents, “decimal tabulators” are used (which are based on the decimal separator character of the numbers).

But what if the documents contain numbers from different countries and the numbers aren’t formatted in the right way? Let’s take a closer look at this!

HDI: Decimal point or comma?

Some word processors assume the most general case: the decimal separator is either a period (aka point) or a comma. If we rely on this and align the numbers according to the first separator encountered from the right, everything will be fine.
Other word processors use what is defined at the system level in the regional parameters.

… Hmmmm … this isn’t so simple after all …

In the first case, large numbers formatted “American” style, such as 123,456,789 (without decimal places), won’t align correctly with 3.1416!
In the second case, “comma” numbers won’t align correctly if the expected decimal separator is a period.

Solution?

To overcome this problem, starting with 4D v18 R5, 4D Write Pro lets you specify this setting for each document. You can choose to align numbers either to:

  1. the point,
  2. the comma,
  3. the first one found,
  4. or finally, to the separator defined in the operating system.

In order to maximize compatibility (with MS Word in particular) option #3 is chosen by default when creating new documents. When migrating 4D Write documents to 4D Write Pro, the system-defined separator is still chosen by default.

In any case, this option can be modified to adapt to each document. It doesn’t modify the document contents in any way. It only modifies the layout of the content, when displayed.

If you have documents from various sources, this option will probably be of great help! If not, then don’t change anything and everything will continue to work “as before”.

Code sample

As you can see in the sample below, the number containing a point is not correctly aligned:

As long as a comma is defined as the decimal separator in the system, both of the following code samples will give the same result.

WP SET ATTRIBUTES([SAMPLE]WP; wk tab decimal separator; wk system)
//OR
WP SET ATTRIBUTES([SAMPLE]WP; wk tab decimal separator; wk comma)

 

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.