Hello, i start become crazy.
I have maked a big script in node red using the function node, now i deleted all just to understand what is wrong.
Please help.
Just a timestamp and a function node with this code .
I read 3 objects from flow or global (there is no difference), i write only the first object and all 3 get the same value.
Here is the output.
What is wrong ?
thank you
var tmp = {};
flow.set("simpos20",tmp);
flow.set("simpos50",tmp);
flow.set("simpos90",tmp);
var simpos20 = flow.get("simpos20");
var simpos50 = flow.get("simpos50");
var simpos90 = flow.get("simpos90");
node.warn(simpos20);
node.warn(simpos50);
node.warn(simpos90);
simpos20[1] = {"text":"hello"};
node.warn(simpos20);
node.warn(simpos50);
node.warn(simpos90);
return msg;
[
{
"id": "03084b6a8123d65d",
"type": "function",
"z": "4895129379e58dc6",
"name": "",
"func": "var tmp = {};\n\nflow.set(\"simpos20\",tmp);\nflow.set(\"simpos50\",tmp);\nflow.set(\"simpos90\",tmp);\n\nvar simpos20 = flow.get(\"simpos20\");\nvar simpos50 = flow.get(\"simpos50\");\nvar simpos90 = flow.get(\"simpos90\");\n\nnode.warn(simpos20);\nnode.warn(simpos50);\nnode.warn(simpos90);\n\n\nsimpos20[1] = {\"text\":\"hello\"};\n\nnode.warn(simpos20);\nnode.warn(simpos50);\nnode.warn(simpos90);\n\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 380,
"y": 240,
"wires": [
[]
]
},
{
"id": "eaafbd92ddb9c638",
"type": "inject",
"z": "4895129379e58dc6",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 210,
"y": 240,
"wires": [
[
"03084b6a8123d65d"
]
]
}
]