Skip to content

Instantly share code, notes, and snippets.

@cman2016
Created January 17, 2017 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cman2016/59c3e0c965954ce5f9b15c4a96b5a8de to your computer and use it in GitHub Desktop.
Save cman2016/59c3e0c965954ce5f9b15c4a96b5a8de to your computer and use it in GitHub Desktop.
global variable example

A global variable example: saving and restore value

[{"id":"303a2bf8.6fce74","type":"tab","label":"Flow 3"},{"id":"137af095.019a0f","type":"inject","z":"303a2bf8.6fce74","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":196,"y":148,"wires":[["8e75af69.8d1b1"]]},{"id":"d5a12ddd.ff09e","type":"debug","z":"303a2bf8.6fce74","name":"","active":true,"console":"false","complete":"false","x":529,"y":148,"wires":[]},{"id":"8e75af69.8d1b1","type":"function","z":"303a2bf8.6fce74","name":"I set here","func":"context.global.myrandom = \"prova\";\nmsg.payload = \"local payload \";\nreturn msg;","outputs":1,"noerr":0,"x":363,"y":148,"wires":[["d5a12ddd.ff09e"]]},{"id":"63552289.87793c","type":"inject","z":"303a2bf8.6fce74","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":263.9999694824219,"y":278.2221984863281,"wires":[["28a72d11.4d31f2"]]},{"id":"ed285a44.391998","type":"debug","z":"303a2bf8.6fce74","name":"","active":true,"console":"false","complete":"false","x":596.9999694824219,"y":278.2221984863281,"wires":[]},{"id":"28a72d11.4d31f2","type":"function","z":"303a2bf8.6fce74","name":"I show here","func":"msg.payload = \"Global value=\" + context.global.myrandom;\nreturn msg;","outputs":1,"noerr":0,"x":430.9999694824219,"y":278.2221984863281,"wires":[["ed285a44.391998"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment