# Make an ARRAY after a text input node.

**URL:** https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236
**Category:** General
**Created:** [3 October 2019 06:42 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236 "2019-10-03T06:42:43Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![Nodeblue](https://avatars.discourse-cdn.com/v4/letter/n/c67d28/32.png) [@Nodeblue](https://discourse.nodered.org/u/Nodeblue)
#### Post date: [3 October 2019 06:42 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/1 "2019-10-03T06:42:43Z")

</div>

Hi, I'm a lost beginner.  
Want to join 14 text input node to an ARRAY to send to an S7 PLC.  
ARRAY should be updated immediately when any of the text input node is updated.

ARRAY looks like this:

{"signal":"Av-restid","path":"DB4,DWORD26..13","error":0,"value":[0,27600000,27600000,27600000,27600000,27600000,27600000,27600000,27600000,27600000,27600000,27600000,27600000,27600000]}

```auto
[{"id":"4baf23af.ed80f4","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"495d4970.0c4c6","type":"s7comm read","z":"4baf23af.ed80f4","connection":"e971ffef.8d56b8","payload":"{\"S7_Type\":\"DB\",\"S7_DBnum\":\"4\",\"S7_Datatype\":\"D\",\"S7_Offset\":\"26\",\"S7_BitOffset\":\"0\",\"S7_Quantity\":\"14\",\"S7_Name\":\"Av-restid\"}","s7Name":"Av-restid","topic":"","name":"","signalSetted":false,"none":"false","repeat":"7","once":true,"x":85,"y":200,"wires":[["f11c0d23.979ec8","9f44a39.f764c6","95388777.87a83","76eec174.a1b018","f977e8ce.f98c","dacf6b0b.ecb35","daced7d3.c9b27","b3106292.086a6","8783fff0.36791","31f1a15e.99567e","627c9bc5.1bae9c","a642ed10.df5658","bdb27c88.91ea98","764c9d45.7dc9a4"]]},{"id":"30d511f9.c94e56","type":"moment","z":"4baf23af.ed80f4","name":"","topic":"","input":"payload.value[0]","inputType":"msg","inTz":"Etc/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_gb","output":"","outputType":"msg","outTz":"Etc/UTC","x":312.5,"y":270,"wires":[["d5f1c400.c5d618"]]},{"id":"d5f1c400.c5d618","type":"ui_text_input","z":"4baf23af.ed80f4","name":"","label":"Måndag tid 1","tooltip":"","group":"38e6ec70.739054","order":2,"width":6,"height":1,"passthru":false,"mode":"time","delay":"100","topic":"1","x":500,"y":270,"wires":[["28c0da12.6312a6"]]},{"id":"d94dd544.9faee","type":"s7comm write","z":"4baf23af.ed80f4","connection":"e971ffef.8d56b8","payload":"{\"S7_Type\":\"DB\",\"S7_DBnum\":\"4\",\"S7_Datatype\":\"D\",\"S7_Offset\":\"26\",\"S7_BitOffset\":\"0\",\"S7_Quantity\":\"14\",\"S7_Name\":\"Av-restid\"}","s7Name":"Av-restid","topic":"","name":"","signalSetted":false,"x":1051.5,"y":206,"wires":[["7a62e813.04bf7"]]},{"id":"e72ea8ec.7de7","type":"function","z":"4baf23af.ed80f4","name":"","func":"var msg_out = {payload:{value:[msg.payload]}};\nreturn msg_out;","outputs":1,"noerr":0,"x":853.5,"y":266,"wires":[["7a62e813.04bf7","d94dd544.9faee"]]},{"id":"f11c0d23.979ec8","type":"moment","z":"4baf23af.ed80f4","name":"","topic":"","input":"payload.value[1]","inputType":"msg","inTz":"Etc/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_gb","output":"","outputType":"msg","outTz":"Etc/UTC","x":307,"y":322,"wires":[["71e2995c.7dc9c"]]},{"id":"71e2995c.7dc9c","type":"ui_text_input","z":"4baf23af.ed80f4","name":"Måndag tid 2","label":"Måndag tid 2","tooltip":"","group":"38e6ec70.739054","order":3,"width":6,"height":1,"passthru":false,"mode":"time","delay":"100","topic":"2","x":491.5,"y":321,"wires":[["28c0da12.6312a6"]]},{"id":"166e9c34.f71294","type":"function","z":"4baf23af.ed80f4","name":"","func":"var msg_out = {payload:{value:[msg.payload]}};\nreturn msg_out;","outputs":1,"noerr":0,"x":851,"y":320,"wires":[[]]},{"id":"9f44a39.f764c6","type":"moment","z":"4baf23af.ed80f4","name":"","topic":"","input":"payload.value[2]","inputType":"msg","inTz":"Etc/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_gb","output":"","outputType":"msg","outTz":"Etc/UTC","x":305,"y":367,"wires":[["cc65950e.de7d"]]},{"id":"cc65950e.de7d","type":"ui_text_input","z":"4baf23af.ed80f4","name":"","label":"Tisdag tid 1","tooltip":"","group":"38e6ec70.739054","order":4,"width":6,"height":1,"passthru":false,"mode":"time","delay":"100","topic":"3","x":489.5,"y":366,"wires":[["28c0da12.6312a6"]]},{"id":"fc82fc40.25b0c8","type":"function","z":"4baf23af.ed80f4","name":"","func":"var msg_out = {payload:{value:[msg.payload]}};\nreturn msg_out;","outputs":1,"noerr":0,"x":849,"y":365,"wires":[[]]},{"id":"95388777.87a83","type":"moment","z":"4baf23af.ed80f4","name":"","topic":"","input":"payload.value[3]","inputType":"msg","inTz":"Etc/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_gb","output":"","outputType":"msg","outTz":"Etc/UTC","x":303,"y":413,"wires":[["7940281c.dd6058"]]},{"id":"7940281c.dd6058","type":"ui_text_input","z":"4baf23af.ed80f4","name":"","label":"Tisdag tid 2","tooltip":"","group":"38e6ec70.739054","order":5,"width":6,"height":1,"passthru":false,"mode":"time","delay":"100","topic":"4","x":487.5,"y":412,"wires":[["28c0da12.6312a6"]]},{"id":"bfa2a6ee.0d8df","type":"function","z":"4baf23af.ed80f4","name":"","func":"var msg_out = {payload:{value:[msg.payload]}};\nreturn msg_out;","outputs":1,"noerr":0,"x":847,"y":411,"wires":[[]]},{"id":"76eec174.a1b018","type":"moment","z":"4baf23af.ed80f4","name":"","topic":"","input":"payload.value[4]","inputType":"msg","inTz":"Etc/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_gb","output":"","outputType":"msg","outTz":"Etc/UTC","x":306,"y":455,"wires":[["42cd5cbe.35c94c"]]},{"id":"42cd5cbe.35c94c","type":"ui_text_input","z":"4baf23af.ed80f4","name":"","label":"Onsdag tid 1","tooltip":"","group":"38e6ec70.739054","order":6,"width":6,"height":1,"passthru":false,"mode":"time","delay":"0","topic":"","x":490.5,"y":454,"wires":[[]]},{"id":"af8784d8.9da1a","type":"function","z":"4baf23af.ed80f4","name":"","func":"var msg_out = {payload:{value:[msg.payload]}};\nreturn msg_out;","outputs":1,"noerr":0,"x":850,"y":453,"wires":[[]]},{"id":"f977e8ce.f98c","type":"moment","z":"4baf23af.ed80f4","name":"","topic":"","input":"payload.value[5]","inputType":"msg","inTz":"Etc/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_gb","output":"","outputType":"msg","outTz":"Etc/UTC","x":306,"y":492,"wires":[["dddc84d4.2c7818"]]},{"id":"dddc84d4.2c7818","type":"ui_text_input","z":"4baf23af.ed80f4","name":"","label":"Onsdag tid 2","tooltip":"","group":"38e6ec70.739054","order":7,"width":6,"height":1,"passthru":false,"mode":"time","delay":"0","topic":"","x":491.5,"y":491,"wires":[[]]},{"id":"fa5c9c20.c5986","type":"function","z":"4baf23af.ed80f4","name":"","func":"var msg_out = {payload:{value:[msg.payload]}};\nreturn msg_out;","outputs":1,"noerr":0,"x":851,"y":490,"wires":[[]]},{"id":"dacf6b0b.ecb35","type":"moment","z":"4baf23af.ed80f4","name":"","topic":"","input":"payload.value[6]","inputType":"msg","inTz":"Etc/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_gb","output":"","outputType":"msg","outTz":"Etc/UTC","x":304,"y":534,"wires":[["d047835c.c53e08"]]},{"id":"d047835c.c53e08","type":"ui_text_input","z":"4baf23af.ed80f4","name":"","label":"Torsdag tid 1","tooltip":"","group":"38e6ec70.739054","order":8,"width":6,"height":1,"passthru":false,"mode":"time","delay":"0","topic":"","x":488.5,"y":533,"wires":[[]]},{"id":"d3e602c4.aa8f","type":"function","z":"4baf23af.ed80f4","name":"","func":"var msg_out = {payload:{value:[msg.payload]}};\nreturn msg_out;","outputs":1,"noerr":0,"x":848,"y":532,"wires":[[]]},{"id":"daced7d3.c9b27","type":"moment","z":"4baf23af.ed80f4","name":"","topic":"","input":"payload.value[7]","inputType":"msg","inTz":"Etc/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_gb","output":"","outputType":"msg","outTz":"Etc/UTC","x":304,"y":571,"wires":[["66ffa3e1.e57664"]]},{"id":"66ffa3e1.e57664","type":"ui_text_input","z":"4baf23af.ed80f4","name":"","label":"Torsdag tid 2","tooltip":"","group":"38e6ec70.739054","order":9,"width":6,"height":1,"passthru":false,"mode":"time","delay":"0","topic":"","x":489.5,"y":570,"wires":[[]]},{"id":"fdbe4ce3.12d4a","type":"function","z":"4baf23af.ed80f4","name":"","func":"var msg_out = {payload:{value:[msg.payload]}};\nreturn msg_out;","outputs":1,"noerr":0,"x":849,"y":569,"wires":[[]]},{"id":"b3106292.086a6","type":"moment","z":"4baf23af.ed80f4","name":"","topic":"","input":"payload.value[8]","inputType":"msg","inTz":"Etc/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_gb","output":"","outputType":"msg","outTz":"Etc/UTC","x":303,"y":610,"wires":[["65f29c78.bee2ac"]]},{"id":"65f29c78.bee2ac","type":"ui_text_input","z":"4baf23af.ed80f4","name":"","label":"Fredag tid 1","tooltip":"","group":"38e6ec70.739054","order":10,"width":6,"height":1,"passthru":false,"mode":"time","delay":"0","topic":"","x":487.5,"y":609,"wires":[[]]},{"id":"c3e1675c.4625b","type":"function","z":"4baf23af.ed80f4","name":"","func":"var msg_out = {payload:{value:[msg.payload]}};\nreturn msg_out;","outputs":1,"noerr":0,"x":847,"y":608,"wires":[[]]},{"id":"8783fff0.36791","type":"moment","z":"4baf23af.ed80f4","name":"","topic":"","input":"payload.value[9]","inputType":"msg","inTz":"Etc/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_gb","output":"","outputType":"msg","outTz":"Etc/UTC","x":303,"y":647,"wires":[["10327704.f44bd1"]]},{"id":"10327704.f44bd1","type":"ui_text_input","z":"4baf23af.ed80f4","name":"","label":"Fredag tid 2","tooltip":"","group":"38e6ec70.739054","order":11,"width":6,"height":1,"passthru":false,"mode":"time","delay":"0","topic":"","x":488.5,"y":646,"wires":[[]]},{"id":"ee1d58f5.d19e78","type":"function","z":"4baf23af.ed80f4","name":"","func":"var msg_out = {payload:{value:[msg.payload]}};\nreturn msg_out;","outputs":1,"noerr":0,"x":848,"y":645,"wires":[[]]},{"id":"31f1a15e.99567e","type":"moment","z":"4baf23af.ed80f4","name":"","topic":"","input":"payload.value[10]","inputType":"msg","inTz":"Etc/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_gb","output":"","outputType":"msg","outTz":"Etc/UTC","x":301,"y":689,"wires":[["beebce06.67baf8"]]},{"id":"beebce06.67baf8","type":"ui_text_input","z":"4baf23af.ed80f4","name":"","label":"Lördag tid 1","tooltip":"","group":"38e6ec70.739054","order":12,"width":6,"height":1,"passthru":false,"mode":"time","delay":"0","topic":"","x":485.5,"y":688,"wires":[[]]},{"id":"20918187.9e2d16","type":"function","z":"4baf23af.ed80f4","name":"","func":"var msg_out = {payload:{value:[msg.payload]}};\nreturn msg_out;","outputs":1,"noerr":0,"x":845,"y":687,"wires":[[]]},{"id":"627c9bc5.1bae9c","type":"moment","z":"4baf23af.ed80f4","name":"","topic":"","input":"payload.value[11]","inputType":"msg","inTz":"Etc/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_gb","output":"","outputType":"msg","outTz":"Etc/UTC","x":301,"y":726,"wires":[["7cef45fb.905eac"]]},{"id":"7cef45fb.905eac","type":"ui_text_input","z":"4baf23af.ed80f4","name":"","label":"Lördag tid 2","tooltip":"","group":"38e6ec70.739054","order":13,"width":6,"height":1,"passthru":false,"mode":"time","delay":"0","topic":"","x":486.5,"y":725,"wires":[[]]},{"id":"cb420276.b270e","type":"function","z":"4baf23af.ed80f4","name":"","func":"var msg_out = {payload:{value:[msg.payload]}};\nreturn msg_out;","outputs":1,"noerr":0,"x":846,"y":724,"wires":[[]]},{"id":"a642ed10.df5658","type":"moment","z":"4baf23af.ed80f4","name":"","topic":"","input":"payload.value[12]","inputType":"msg","inTz":"Etc/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_gb","output":"","outputType":"msg","outTz":"Etc/UTC","x":297,"y":769,"wires":[["749e6bf7.77e004"]]},{"id":"749e6bf7.77e004","type":"ui_text_input","z":"4baf23af.ed80f4","name":"","label":"Söndag tid 1","tooltip":"","group":"38e6ec70.739054","order":14,"width":6,"height":1,"passthru":false,"mode":"time","delay":"0","topic":"","x":481.5,"y":768,"wires":[[]]},{"id":"daf079f0.5ec6","type":"function","z":"4baf23af.ed80f4","name":"","func":"var msg_out = {payload:{value:[msg.payload]}};\nreturn msg_out;","outputs":1,"noerr":0,"x":841,"y":767,"wires":[[]]},{"id":"bdb27c88.91ea98","type":"moment","z":"4baf23af.ed80f4","name":"","topic":"","input":"payload.value[13]","inputType":"msg","inTz":"Etc/UTC","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_gb","output":"","outputType":"msg","outTz":"Etc/UTC","x":297,"y":806,"wires":[["edccc666.db5418"]]},{"id":"edccc666.db5418","type":"ui_text_input","z":"4baf23af.ed80f4","name":"","label":"Söndag tid 2","tooltip":"","group":"38e6ec70.739054","order":15,"width":6,"height":1,"passthru":false,"mode":"time","delay":"0","topic":"","x":482.5,"y":805,"wires":[[]]},{"id":"4df27d6d.9652ac","type":"function","z":"4baf23af.ed80f4","name":"","func":"var msg_out = {payload:{value:[msg.payload]}};\nreturn msg_out;","outputs":1,"noerr":0,"x":842,"y":804,"wires":[[]]},{"id":"7a62e813.04bf7","type":"debug","z":"4baf23af.ed80f4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1052.5,"y":127,"wires":[]},{"id":"28c0da12.6312a6","type":"debug","z":"4baf23af.ed80f4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":841.5,"y":115,"wires":[]},{"id":"764c9d45.7dc9a4","type":"debug","z":"4baf23af.ed80f4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":698.5,"y":27,"wires":[]},{"id":"e971ffef.8d56b8","type":"s7comm","z":"","ip":"192.168.1.86","port":"102","rack":"0","slot":"2","payload":[{"S7_Type":"DB","S7_DBnum":"5","S7_Datatype":"R","S7_Offset":"0","S7_BitOffset":"0","S7_Quantity":"1","S7_Name":"UteTemprtur"},{"S7_Type":"DB","S7_DBnum":"5","S7_Datatype":"R","S7_Offset":"20","S7_BitOffset":"0","S7_Quantity":"1","S7_Name":"Tanktopp"},{"S7_Type":"DB","S7_DBnum":"4","S7_Datatype":"D","S7_Offset":"26","S7_BitOffset":"0","S7_Quantity":"14","S7_Name":"Av-restid"},{"S7_Type":"DB","S7_DBnum":"4","S7_Datatype":"D","S7_Offset":"26","S7_BitOffset":"0","S7_Quantity":"1","S7_Name":"Av-Restidwrite"}]},{"id":"38e6ec70.739054","type":"ui_group","z":"","name":"Default","tab":"a4dc9bca.e6c778","order":2,"disp":true,"width":"6","collapse":false},{"id":"a4dc9bca.e6c778","type":"ui_tab","z":"","name":"Test","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)
#### Post date: [3 October 2019 07:04 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/2 "2019-10-03T07:04:19Z")

</div>

You can easily create and add to an array in javascript within a function node, a quick google will find lots of tutorials to show you how.

---

<div class="post-metadata">

### Author: ![Nodeblue](https://avatars.discourse-cdn.com/v4/letter/n/c67d28/32.png) [@Nodeblue](https://discourse.nodered.org/u/Nodeblue)
#### Post date: [3 October 2019 08:43 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/3 "2019-10-03T08:43:24Z")

</div>

What I do not understand is how to see the difference in the received Payload from text input. Have read something about "Topic" but do not understand.

---

<div class="post-metadata">

### Author: ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)
#### Post date: [3 October 2019 09:39 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/4 "2019-10-03T09:39:30Z")

</div>

Add a debug node after your text input node and give us an example...

---

<div class="post-metadata">

### Author: ![Nodeblue](https://avatars.discourse-cdn.com/v4/letter/n/c67d28/32.png) [@Nodeblue](https://discourse.nodered.org/u/Nodeblue)
#### Post date: [3 October 2019 10:19 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/5 "2019-10-03T10:19:20Z")

</div>

Uses this code to send single value. Not to an ARRAY.

> var msg\_out = {payload:{value:[msg.payload]}};  
> return msg\_out;

```auto
2019-10-03 12:18:19node: 28c0da12.6312a6
1 : msg.payload : number
25200000
2019-10-03 12:18:19node: 28c0da12.6312a6
1 : msg.payload : number
27600000
2019-10-03 12:18:26node: 28c0da12.6312a6
3 : msg.payload : number
16800000
2019-10-03 12:18:26node: 28c0da12.6312a6
3 : msg.payload : number
14700000
2019-10-03 12:18:26node: 28c0da12.6312a6
3 : msg.payload : number
17400000

```

---

<div class="post-metadata">

### Author: ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)
#### Post date: [3 October 2019 10:25 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/6 "2019-10-03T10:25:31Z")

</div>

It would be more useful to give us an example of the message you are sending to your function node rather than examples of what you know doesn't work.

Assuming all your data is in the one message going into your function, you will need to create the array and push the data into that array before you return it  
[https://www.w3schools.com/jsref/jsref\_push.asp](https://www.w3schools.com/jsref/jsref_push.asp)

---

<div class="post-metadata">

### Author: ![Nodeblue](https://avatars.discourse-cdn.com/v4/letter/n/c67d28/32.png) [@Nodeblue](https://discourse.nodered.org/u/Nodeblue)
#### Post date: [3 October 2019 10:27 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/7 "2019-10-03T10:27:37Z")

</div>

How do I implement that TOPIC determines the location in ARRAY.

In the debug , the value of TOPIC is: 1 and 3

ARRAY looks like this:

{"signal":"Av-restid","path":"DB4,DWORD26..13","error":0,"value":[0,27600000,27600000,27600000,27600000,27600000,27600000,27600000,27600000,27600000,27600000,27600000,27600000,27600000]}

 ![bild](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/ea84ee2f78a93d65eecf50c9a43d515e2b908fd1.png)

---

<div class="post-metadata">

### Author: ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)
#### Post date: [3 October 2019 10:46 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/8 "2019-10-03T10:46:19Z")

</div>

Lets take a step back.  
You are taking one message splitting it into 14 messages.  
Do you need to merge the 14 messages back into 1 message? If so look at the `join` node

Given there are 14 values in your array I'm not sure how you could use 1 or 3 to define all the positions in the array. But you can define the position in an array using `splice`  
[https://www.w3schools.com/jsref/jsref\_splice.asp](https://www.w3schools.com/jsref/jsref_splice.asp)

---

<div class="post-metadata">

### Author: ![Nodeblue](https://avatars.discourse-cdn.com/v4/letter/n/c67d28/32.png) [@Nodeblue](https://discourse.nodered.org/u/Nodeblue)
#### Post date: [3 October 2019 10:58 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/9 "2019-10-03T10:58:24Z")

</div>

`Do you need to merge the 14 messages back into 1 message?`Yes

How should I be able to tell which text input node Payload is sent from?

---

<div class="post-metadata">

### Author: ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)
#### Post date: [3 October 2019 11:03 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/10 "2019-10-03T11:03:18Z")

</div>

Take a look at the config panel for your text nodes where you can specify a topic.

---

<div class="post-metadata">

### Author: ![Nodeblue](https://avatars.discourse-cdn.com/v4/letter/n/c67d28/32.png) [@Nodeblue](https://discourse.nodered.org/u/Nodeblue)
#### Post date: [3 October 2019 12:12 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/11 "2019-10-03T12:12:35Z")

</div>

Where should TOPIC be placed?

```auto
var msg_out = {payload:{value:[*topic.1*][msg.payload]}};
 return msg_out;

```

 ![bild](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/70e4781929f3c8f0431d36e12909cc57d49b21c4.png)

---

<div class="post-metadata">

### Author: ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)
#### Post date: [3 October 2019 12:21 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/12 "2019-10-03T12:21:05Z")

</div>

In the box labelled “Topic” ?

---

<div class="post-metadata">

### Author: ![Nodeblue](https://avatars.discourse-cdn.com/v4/letter/n/c67d28/32.png) [@Nodeblue](https://discourse.nodered.org/u/Nodeblue)
#### Post date: [4 October 2019 05:39 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/13 "2019-10-04T05:39:25Z")

</div>

Where should "Topic" be placed in the code.

var msg\_out = {payload:{value:[_topic.1_][msg.payload]}}; return msg\_out;

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [4 October 2019 05:54 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/14 "2019-10-04T05:54:23Z")

</div>

`{topic:'thisisthetopic',payload:'thisisthepayload'}`

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [4 October 2019 06:44 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/15 "2019-10-04T06:44:50Z")

</div>

Have a look at the node red docs. There is a section on working with messages that you may find useful. Also look at the rest of the docs of course.

---

<div class="post-metadata">

### Author: ![Nodeblue](https://avatars.discourse-cdn.com/v4/letter/n/c67d28/32.png) [@Nodeblue](https://discourse.nodered.org/u/Nodeblue)
#### Post date: [4 October 2019 12:16 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/16 "2019-10-04T12:16:59Z")

</div>

Feature I'm trying to create:  
Topic = 1 move payload to array place 1  
Topic = 2 move payload to array place 2  
Etc

The code below does not work. Just to try to explain

```auto

If (msg.topic==1) {
    var msg1 = msg.payload;
}

If (msg.topic==2) {
    var msg2 = msg.payload;
}
If (msg.topic==3) {
    var msg3 = msg.payload;
}
If (msg.topic==4) {
    var msg4 = msg.payload;
}

var array= {payload:[msg1, msg2, msg3 , msg4]}

return array;

```

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [4 October 2019 12:45 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/17 "2019-10-04T12:45:19Z")

</div>

It is not a good idea to use variables starting with msg as simple variables, keep names like that for messages, it will avoid confusion in the future. Also consider whether the topic is a string or a number, if it is a string then you need to compare against "1". Finally, what do you think the values of msg2, 3 and 4 that you are putting into the array will be when you get a topic of 1?  
I suspect you may want to feed all your input messages into a Join node set to generate key/value pairs before passing that on to a function node. Alternatively look in the node-red doc on writing functions. In particular the section where it talks about using node context to save information so that data from previous messages is made available in the function.

---

<div class="post-metadata">

### Author: ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)
#### Post date: [4 October 2019 13:20 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/18 "2019-10-04T13:20:29Z")

</div>

Sometimes Node-RED makes it easier for you...

```auto
[{"id":"5a193e81.d3d9b8","type":"inject","z":"fde1fdc8.696df","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":140,"wires":[["dfdf77b.4aebe88","2344bf48.e7f348","6c84b3d9.4ee76c","fc97af08.a91658"]]},{"id":"dfdf77b.4aebe88","type":"function","z":"fde1fdc8.696df","name":"Topic 1","func":"msg.topic=\"1\"\nmsg.payload = \"en\"\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":140,"wires":[["f044da86.a607c8"]]},{"id":"2344bf48.e7f348","type":"function","z":"fde1fdc8.696df","name":"Topic 2","func":"msg.topic=\"2\"\nmsg.payload = \"to\"\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":80,"wires":[["f044da86.a607c8"]]},{"id":"6c84b3d9.4ee76c","type":"function","z":"fde1fdc8.696df","name":"Topic 3","func":"msg.topic=\"3\"\nmsg.payload = \"tre\"\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":200,"wires":[["f044da86.a607c8"]]},{"id":"fc97af08.a91658","type":"function","z":"fde1fdc8.696df","name":"Topic 4","func":"msg.topic=\"4\"\nmsg.payload = \"fire\"\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":40,"wires":[["f044da86.a607c8"]]},{"id":"f044da86.a607c8","type":"join","z":"fde1fdc8.696df","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":460,"y":180,"wires":[["6d23e5fe.225b14"]]},{"id":"bd5419ab.980818","type":"debug","z":"fde1fdc8.696df","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":320,"wires":[]},{"id":"6d23e5fe.225b14","type":"change","z":"fde1fdc8.696df","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":240,"wires":[["bd5419ab.980818"]]}]

```

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [5 October 2019 01:06 UTC](https://discourse.nodered.org/t/make-an-array-after-a-text-input-node/16236/19 "2019-10-05T01:06:31Z")

</div>

> [@Nodeblue](#):
>
> var array= {payload:[msg1, msg2, msg3 , msg4]} return array;

Yeah, that won't work. Try this instead...

```auto
return [msg1, msg2, msg3, msg4];

```

This assumes `msg1` ~ `msg4` are all objects (i.e. `{payload: "some value you wanna send"}`)

And just in case I missed something, you would need to set the function to have 4 outputs and `msg1` would travel out of pin 1, `msg2` would travel out of pin 2... Etc.

And just incase I missed something else, you can send msg1~4 out the same pin (serially) using either `return [[msg1, msg2, msg3, msg4]]` or `node.send([msg1, msg2, msg3, msg4]);`.

I highly recommend reading the Excellent documentation about  
[Working with messages](https://nodered.org/docs/user-guide/messages). So many golden nuggets there to simplify your life and experience with node-red.

Disclaimer....  
The code snippets above are off the top of my head. RTFM 😉
