Hello guys,
Sorry, this is probably something very well known to the more experienced but I couldn't find anything about so here I am.
Is it possible to use indirect referencing to variable names in context/flow/global get and set commands? I have a situation where I'll have around 60 variables that will be read/written to one at a time, and I'd like to use the same function node to do it all.
I'll receive the name of the variable as a string in msg.payload.id
, here's an example of the kind of logic I'd like to use:
var id = msg.payload.id;
var alive = id + "_alive";
var checkalive = flow.get(alive);
var down = id + "_down";
var checkdown = flow.get(down);
...
flow.set(alive, true);
flow.set(down, false);
msg.payload.id
will always be a 3 char code like IMP, SUP, MTE, etc. So I want to end referencing variables IMP_down, IMP_alive, etc.
Is this possible?
Thank you all!