No space before my unit suffix, please


Recommended Posts

Many engineering units are customarily placed immediately after the number without a space, for example the inch mark for either pressure or length, ft, degree mark for temperature, etc., and look odd if there is a space between the value and the unit.

If you stop adding a space to whatever is entered in the units box for display, then in those cases where it's needed, it can be added, but then we'd have the option not to have it.

Link to comment
Share on other sites

You can do it now using Format() and not specifying units or caption. For example:

Format("My value: %.3fUnits", myChannel[0])

Unfortunately, if we made every possible combination an option in the properties it would be completely unwieldy. That's why we have scripting. We make the most common functionality available through properties and then give a powerful scripting option for anything less common.

Link to comment
Share on other sites

I wasn't saying be all things to all people, I was saying remove the extra space for everybody, and the people who want it can put it back in as part of the units string (whereas I can't take out one that isn't there).

Nevertheless, the Format() solution is adequate.

Link to comment
Share on other sites

True, but:

1-The most common use is with a space (you are the first to mention a need to not have it in 10 years)

2-If we change it now, it will cause all the existing apps to be misformatted.

(I'm not trying to put down your suggestion in any way, simply tell you why its not going to change in this case)

Link to comment
Share on other sites

  • 10 months later...

The degree symbol (usually for temperature but in this case for angle) is one where I'd REALLY like to lose the extra space, so I tried

Format("%0.2f°", N7040[0] / 100.0)

but without success. It strips the degree symbol and just prints the value to 2 places. So I tried

DoubleToStr(N7040[0] / 100.0) + "°"

but that does exactly the same thing (prints the string and omits the symbol).

Link to comment
Share on other sites

I wasn't going to say it...

Sure: the issue appears to actually be in the script parser. It doesn't like the "°", probably because its an extended character and the script parser really only looks at standard ASCII. So, what you do is create a static text component somewhere hidden (set visibility to 0, or put it on a scratch page or something). Give it a name, like "degreeChar", then you can pull in the degree character by accessing the strText member of that component. So, your expression becomes:

DoubleToStr(N7040[0] / 100.0) + component.degreeChar.strText

A little roundabout, but works. You could make it cleaner by setting a global variable in startup to that char:

global string degreeChar = component.degreeChar.strText

then use degreeChar in any expression you want to use it. Note that it won't work in non-expression fields, but those should support the character directly anyway.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.