250 byte string, position - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: 250 byte string, position (/showthread.php?tid=4066) |
250 byte string, position - Dré - 29.05.2022 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? RE: 250 byte string, position - admin - 30.05.2022 Set Additional class to pre, add this to Custom CSS: Code: .pre { 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. Code: v1 = 1.234 RE: 250 byte string, position - Dré - 31.05.2022 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. Code: v1 = 2.234 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 Code: v1 = 0.234 I hope you can help me with this. RE: 250 byte string, position - admin - 01.06.2022 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. RE: 250 byte string, position - Dré - 01.06.2022 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? RE: 250 byte string, position - admin - 01.06.2022 You have comma after: pre, Remove it and it should work. RE: 250 byte string, position - Dré - 01.06.2022 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. RE: 250 byte string, position - admin - 01.06.2022 -- is for Lua comments. Put CSS comments between /* */ |