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.

250 byte string, position
I have many virtual groupsadresses.
I was looking to compare them to 1 single string at day.

but i also will try to have nice view of it.

is it possible to set the value on the 10th position of the '250 byte string'?

so the first 9 position are for electric use value, the 10 to 19 positions are for return electricity value and so on.

or another solution and maybe more what i like.
if i have a value like 1.456W convert to [space]1.456W
so it always looks like
1.646W    3.967W  3.935W    2.240W
1.784W 13.764W 19.957W 3.345W
This preview doens't work here, because the forum doesn't show multiple spaces)

or isn't this possible because the width of a character isn't the same?
Set Additional class to pre, add this to Custom CSS:
.pre {
  white-space: pre;
  font-family: monospace;

Use string.format to keep values at the same position no matter how many digits they have. 10.3 means print at least 10 character and use 3 decimal places. If the number is larger then the following values will be shifted so adjust width as needed.
v1 = 1.234
v2 = 23.45
v3 = 345.6
v4 = 4567
text = string.format('%10.3fW %10.3fW %10.3fW %10.3fW', v1, v2, v3, v4)
Hi Admin,

Sorry but I tried your script,

i add the first script to Custom CSS '/scada-main/main/editor?id=css'
add pre to the Additional class, pre
I add a groupadres with 250 byte string '0/1/1'
I run the script and sent it to the group adress i added.

v1 = 2.234
v2 = 23.45
v3 = 345.6
v4 = 4567
text = string.format(' %10.3fW %10.3fW %10.3fW %10.3fW', v1, v2, v3, v4)

-- write value (e.g. boolean 'true') to object with group address 1/1/1, datatype must be set for this object
grp.write('0/1/1', text)

I'm not sure what i'm doing wrong, but it didn't work.
Not if i look at the groupadress by it self and not on desktop view of the visualization (not the edit mode).

i got the next value when i sent it to the group adress: 2.234W 23.450W 345.600W 4567.000W
It looks like the %10 didn't work the second part of it (.3f W) works fine.

Is it also possible to got a value like
01.123W, and not 1.123W?

I tried to do it by myself, but all i tried didn't work.

what i try to get is this
v1 = 0.234
v2 = 3.45
v3 = 45.6
v4 = 123.7

string showing like:
00.234 W  03.450 W  45.600 W  123.7 L --(for the first 3 values, always show 2 digits before the .(dot) and 3 digits behond the .(dot) and for value 4, 3 digits before the .(dot) and just 1 behind.
1234567890123456789012345678901234567890 (position of character)

I hope you can help me with this.
This will only work in the visualization viewer. Everywhere else the displayed value will have a single space instead of multiples spaces. But if you click "Set value" then you will see multiple spaces. If it still does not work the right click the value in the viewer, select Inspect and check Rules tab. It should have .pre class with rules there.
More complex formatting like leading zeros has to be coded manually.
as you can see on the picture.
It looks like it works with the CSS code and position, but the viewer doesn't show it on the right way.
The viewer just show 1 space.

I tried this on Firefox and Chrome in the visualization mode for customer.

Maybe you have a idea how i can fix this?

Attached Files Thumbnail(s)
You have comma after: pre,
Remove it and it should work.
I tried at another LM and it is working.

at the LM i was tried at first time i removed all css code an now it works fine.
now i think i know what is wrong, I would add a text commentary to know why this part of code is for.
I used -- to lock out of the code, but this isnt working with CSS.
-- is for Lua comments. Put CSS comments between /* */

Forum Jump: