I am sending some data to a display with 2 lines of 16 char's.
The top line I want to display the amount of Watts taken from the net and the second line the returned to the net. So I want the first string to be exactly 16 chars. I came up with this but that doesn't work in a function node:
var meterreceived = global.get('meter_received'); var regel1 = "Watt in : " + global.get('meter_cons'); var lregel1 = regel1.lenght; for (var i = lregel1; i < 16; i++) regel1 = regel1 + " "; msg.payload = regel1 + "terug: " + meterreceived;
No spaces are inserted when the line is less than 16 chars.
meter_cons is something between 0 and 40000.
I think I have the for wrong but I cannot find someting else.