AnsweredAssumed Answered

Calculation game/challenge

Question asked by Cécile on Dec 21, 2018
Latest reply on Dec 23, 2018 by Cécile

The goal is to prevent text to wrap on a button.


BTNB Button bar width 1419 with 5 segments. One character in the monospace Font "Hack" at 13pts occupies 40pts on that button on a display's 1920x1080.


When the WindowContentWidth is maximized, 1905pts, 47 characters fit on that button.

When the WindowContentWidth is less than 1459, 35 characters fit on that button.

dynamic text.jpg


If you wanted to put the following on that button so that it never wraps and every string gets truncated except those very small, how would you calculate the number of characters you would allow for each string in function of the WindowContentWidth. Note that the number of strings can be 3 or 4. You don't know the number of digits in the string. The string may contain spaces. The space between strings must be at least 2 characters digits worth


table:field1 & char(160) & table::field2 & char(160) & table::field3



Strings Demanding physical exercises Good metabolism wit


Maximized.........47 char total............ Demanding physical exe- Good metabolism wit

at 1499 pts.........37 char total............ Demanding ph- Good metabolis- wit


Hint: breaking occurs first on spaces, tabs then digits characters so you can only separate strings with Char(160) which occupies 1 digit characters space.


Bonus if the method can adapt to other ratios of monospace character/point,




Edited to note that no calc was submitted and, in a sense, I am relieved that people didn't. A pair of solutions that were taking another approach have proven more efficient and easy to achieve the Objective behind the challenge.

Often time, we complicate our lives (and potentially the lives of others) by presenting a referential need instead of the essential need.

1- What is a referential need? a pizza, granola, fish

2- What is an essential need? food, nutrients

3- What is the problem it solves? hunger, sustenance


1- a calc to control the display of several fields values grouped on equal sized buttons of a self adjusting button bar that accomodate the largest individual field;

or a patchwork of grouped button bars

or a tab control!

2- A support to display data

3- columns minimal width to accomodate data and display it legibly, varies; Window resizing affect aestetic, and legibility of content displayed statically on a layout otherwise dynamic.