How to set global variable parameters?

Hi,

I would like to store 5 temperature values in one global object.
I have created the global object with several temp values:

var GlobalTemp = {};
GlobalTemp.a = 10;
GlobalTemp.b = 15;
GlobalTemp.c = 22;
global.set("Temp",GlobalTemp);

and I can read the Global Var and get the values I need:

var work_GlobalTemp = global.get("Temp");

msg.payload = work_GlobalTemp.b;
return msg;

but I have now Idea how to set a speciel value inside the global object with a new value.

Something like global.set ("GlobalTemp".b,19);

Does anyone know how to do this ?

BR
Gawan

Well you can do it in a Change node easy:
Screen Shot 2019-12-22 at 11.49.49 AM

You can modify properties of GlobalTemp the same way that you created them:

work_GlobalTemp.b = 19;
global.set("Temp",GlobalTemp);
msg.payload = global.get("Temp");

As well as using the Change node to access the property directly, you can also do:

global.set ("GlobalTemp.b",19);
1 Like

Perfect, thats exactly what I was looking for !
I do not like using function-nodes ... writing code is more what I prefer:)
Thanks a lot !!