Node Red Global Array Function Node

736 views
Skip to first unread message

Seishuuin Soba

unread,
Apr 14, 2018, 4:05:08 AM4/14/18
to Node-RED
Hi, I just started node red and there's something I would like to try out.

I want to send in a few strings into the same function node, and place them in an array.
etc "John eats cake" into array[0], "Peter drinks tea" into array[1], and so on...

After this, I want to be able to pull these arrays from a different function block. I tried my best to self source for this, but as I am also new to javascript,
I am quite confused.

Is there any example where I could use as a guideline for my use?

Thank you

Mark Setrem

unread,
Apr 14, 2018, 4:15:22 AM4/14/18
to Node-RED

A good place to start  are the docs on the Node-RED website including this useful page about how to work with messages in node-red: https://nodered.org/docs/user-guide/messages

There's lots of tutorials on how to deal with objects and arrays in javascript.
The tutorial on javascript objects and arrays that gets recommended the most is the w3schools ones https://www.w3schools.com/js/js_arrays.asp & https://www.w3schools.com/js/js_objects.asp

Between them they should be able to help you.  If you get stuck, try placing debug nodes along your flow so you can identify where the flow is departing from what you want.

There are also examples on how to pass messages between node on the Node-RED website, the flows on flows.nodered.org and the online tutorials at http://noderedguide.com 

Nick O'Leary

unread,
Apr 14, 2018, 4:22:50 AM4/14/18
to node...@googlegroups.com
One more link to add to Marks reply:


That explains how to use the Function node. In particular, how to store data between calls to the node using Flow context, which can be shared between other nodes.

Nick

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/0402ab7e-8308-4130-9b89-34bcb80c80f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages