This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Change Unit/Suffix automatic
#6
(09.08.2022, 08:33)admin Wrote: grp.create can also update existing objects' properties. But as I've said you won't see this changes in the visualization unless you do a full reload.

Oh did´nt see your reply.
I implemented your script, and it work nice. thanks for the help.

(09.08.2022, 08:14)admin Wrote: Changing units via grp.create will require UI reload for new units to appear.
You can use string data type instead of floating point for value display:
Code:
value = r1 * 0x1000000000000 + r2 * 0x100000000 + r3 * 0x10000 + r4

if value > 999 then
  units = 'MWh'
  value = value / 1000000
else
  units = 'KWh'
  value = value / 1000
end

value = string.format('%.3f', value) .. units
grp.checkupdate('32/1/54', value)
I use this one and gets the string presented with  4.564MWh.

I can change the presentation to 4.56MWh by change '%.3f' to '%.2f'
But how do I change this presentation as the number gets bigger?
So when the number gets bigger it also gets lesser decimals.
Reply


Messages In This Thread
Change Unit/Suffix automatic - by victor.back - 09.08.2022, 07:44
RE: Change Unit/Suffix automatic - by Daniel - 09.08.2022, 07:49
RE: Change Unit/Suffix automatic - by admin - 09.08.2022, 08:14
RE: Change Unit/Suffix automatic - by admin - 09.08.2022, 08:33
RE: Change Unit/Suffix automatic - by victor.back - 09.08.2022, 09:06

Forum Jump: