# Combining values from an Array into a single word

**URL:** <https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003>\
**Category:** General\
**Created:** [5 August 2024 14:18 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003 "2024-08-05T14:18:33Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![haplc2000](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@haplc2000](https://discourse.nodered.org/u/haplc2000)\
**Post date:** [5 August 2024 14:18 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/1 "2024-08-05T14:18:33Z")

</div>

Hello All,

Today is my first day!

I am using Node RED since a few weeks only.

I have an array of values coming from Modbus RTU. I am able to read 4 objects under one array "payload.addressSpaceItems[2].nodeId". THe four objects are given as: see " myisssue 1.jpeg"

What I want to do is to create a single variable in whihc the value of 4 objects shoudl be shpown as 1111.  
I have tried "join" and also "parser" but did not mamange to get a single value.

Thanking youin advance for your help

Here is the code:

```auto
[
    {
        "id": "cef6e0716e26e027",
        "type": "tab",
        "label": "Array to word",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "2b2b6e7c0ab3712e",
        "type": "OPCUA-IIoT-Response",
        "z": "cef6e0716e26e027",
        "name": "CMD",
        "compressStructure": true,
        "showStatusActivities": false,
        "showErrors": false,
        "activateUnsetFilter": false,
        "activateFilters": false,
        "negateFilter": false,
        "filters": [],
        "x": 1170,
        "y": 400,
        "wires": [
            [
                "43da5b273301c159"
            ]
        ]
    },
    {
        "id": "43da5b273301c159",
        "type": "debug",
        "z": "cef6e0716e26e027",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1350,
        "y": 400,
        "wires": []
    },
    {
        "id": "6ded65f94816977d",
        "type": "OPCUA-IIoT-Browser",
        "z": "cef6e0716e26e027",
        "nodeId": "",
        "name": "Browse root",
        "justValue": true,
        "sendNodesToRead": false,
        "sendNodesToBrowser": false,
        "sendNodesToListener": false,
        "multipleOutputs": false,
        "showStatusActivities": false,
        "showErrors": false,
        "recursiveBrowse": true,
        "recursiveDepth": "6",
        "delayPerMessage": 0.2,
        "connector": "041396811b8c7ab1",
        "x": 350,
        "y": 140,
        "wires": [
            [
                "c3999f9e9c598aa2"
            ]
        ]
    },
    {
        "id": "4014dda193b14206",
        "type": "inject",
        "z": "cef6e0716e26e027",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": true,
        "onceDelay": "35",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 150,
        "y": 140,
        "wires": [
            [
                "6ded65f94816977d"
            ]
        ]
    },
    {
        "id": "0fc4c3f983d7998d",
        "type": "function",
        "z": "cef6e0716e26e027",
        "name": "find node ids",
        "func": "var name;\nvar part;\nvar part_tmp;\nvar id_value;\nvar ns, i;\n\n\nfor (var x in msg.payload.browserResults){\n console.log(x);\n console.log(msg.payload.browserResults[x].browseName);\n name = msg.payload.browserResults[x].browseName;\n if (name.includes(\"SFM_5_RunForward\")){\n flow.set('cmd_id',msg.payload.browserResults[x].nodeId);\n }\n if (name.includes(\"SFM_5_OSPValid\")){\n flow.set('osp_id',msg.payload.browserResults[x].nodeId);\n }\n \n if (name.includes(\"SFM_5_ResetErros\")){\n flow.set('RE_id',msg.payload.browserResults[x].nodeId);\n }\n \n \n\n \n //we are using DJTCN to read MVCH2\n if (name.includes(\"Zone1_TCN1\")){\n flow.set('temp_id',msg.payload.browserResults[x].nodeId);\n}\n //we are using B21 to read Energy /value\n if (name.includes(\"B21\")){\n flow.set('L1_id',msg.payload.browserResults[x].nodeId);\n}\n \n //we are using TCN2 - read SNO /value\n if (name.includes(\"Zone2_TCN2\")){\n flow.set('SNO_id',msg.payload.browserResults[x].nodeId);\n }\n \n\n}\nid_value = flow.get(\"temp_id\");\npart = id_value.split(\";\");\npart_tmp = part[0].split(\"=\");\nns = part_tmp[1];\n// reading mv ch2 /value from DJTCN and 80 is being offset from djtcn to mvch/value\npart_tmp = part[1].split(\"=\");\ni = Number(part_tmp[1]) + 80;\n// defining global variable with temp_id for mv ch 2\nflow.set('temp_id_mvch2',\"ns=\"+ ns+ \";i=\"+i);\n\n//setting i to id for mv ch 1 offfset 74\ni = Number(part_tmp[1]) + 74;\n// defining global variable with temp_id for mv ch 1\nflow.set('temp_id_mvch1',\"ns=\"+ ns+ \";i=\"+i);\n\n// reading energy from B21 50392 (B21)- 50430 (L1/value) = 38 is being offset from UMC toEnergy /value\nid_value = flow.get(\"L1_id\");\npart = id_value.split(\";\");\npart_tmp = part[1].split(\"=\");\ni = Number(part_tmp[1]) + 38;\nflow.set('L1_id',\"ns=\"+ ns+ \";i=\"+i);\n\n// reading SNO of Zone2 TCN2 50295- 50269 (SNO/value) = 26 is being offset from UMC toEnergy /value\nid_value = flow.get(\"SNO_id\");\npart = id_value.split(\";\");\npart_tmp = part[1].split(\"=\");\ni = Number(part_tmp[1]) + 26;\nflow.set('SNO_id',\"ns=\"+ ns+ \";i=\"+i);\n\n\n//exporting everything for debuging\n\nmsg.temp_id_mvch1 = flow.get(\"temp_id_mvch1\");\nmsg.temp_id_mvch2 = flow.get(\"temp_id_mvch2\");\nmsg.L1_id = flow.get(\"L1_id\");\nmsg.SNO_id = flow.get(\"SNO_id\");\n\nmsg.osp_id = flow.get(\"osp_id\");\nmsg.cmd_id = flow.get(\"cmd_id\");\nmsg.cmd_id = flow.get(\"RE_id\");\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 550,
        "y": 140,
        "wires": [
            []
        ]
    },
    {
        "id": "b9527564bb86d79c",
        "type": "debug",
        "z": "cef6e0716e26e027",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 730,
        "y": 180,
        "wires": []
    },
    {
        "id": "79641f1b1bf24b3f",
        "type": "comment",
        "z": "cef6e0716e26e027",
        "name": "To convert array to word",
        "info": "turn on if both gpios are true",
        "x": 120,
        "y": 60,
        "wires": []
    },
    {
        "id": "c3999f9e9c598aa2",
        "type": "function",
        "z": "cef6e0716e26e027",
        "name": "find node ids",
        "func": "var name;\nvar part;\nvar part_tmp;\nvar id_value;\nvar ns, i;\n\n\nfor (var x in msg.payload.browserResults){\n console.log(x);\n console.log(msg.payload.browserResults[x].browseName);\n name = msg.payload.browserResults[x].browseName;\n if (name.includes(\"SFM_5_RunForward\")){\n flow.set('cmd_id',msg.payload.browserResults[x].nodeId);\n }\n if (name.includes(\"SFM_5_OSPValid\")){\n flow.set('osp_id',msg.payload.browserResults[x].nodeId);\n }\n \n if (name.includes(\"SFM_5_ResetErros\")){\n flow.set('RE_id',msg.payload.browserResults[x].nodeId);\n }\n \n \n\n \n //we are using DJTCN to read MVCH2\n if (name.includes(\"Zone1_TCN1\")){\n flow.set('temp_id',msg.payload.browserResults[x].nodeId);\n}\n //we are using B21 to read Energy /value\n if (name.includes(\"B21\")){\n flow.set('B21_id',msg.payload.browserResults[x].nodeId);\n}\n \n //we are using TCN2 - read SNO /value\n if (name.includes(\"Zone2_TCN2\")){\n flow.set('SNO_id',msg.payload.browserResults[x].nodeId);\n }\n \n\n}\nid_value = flow.get(\"temp_id\");\npart = id_value.split(\";\");\npart_tmp = part[0].split(\"=\");\nns = part_tmp[1];\n// reading mv ch2 /value from DJTCN and 80 is being offset from djtcn to mvch/value\npart_tmp = part[1].split(\"=\");\ni = Number(part_tmp[1]) + 80;\n// defining global variable with temp_id for mv ch 2\nflow.set('temp_id_mvch2',\"ns=\"+ ns+ \";i=\"+i);\n\n//setting i to id for mv ch 1 offfset 74\ni = Number(part_tmp[1]) + 74;\n// defining global variable with temp_id for mv ch 1\nflow.set('temp_id_mvch1',\"ns=\"+ ns+ \";i=\"+i);\n\n// reading energy from B21 50392 (B21)- 50430 (L1/value) = 86 is the diffetnce is being offset from UMC toEnergy /value\nid_value = flow.get(\"B21_id\");\npart = id_value.split(\";\");\npart_tmp = part[1].split(\"=\");\ni = Number(part_tmp[1]) + 86;\nflow.set('L1_id',\"ns=\"+ ns+ \";i=\"+i);\n\n//setting i to id for AC Import offfset 32\ni = Number(part_tmp[1]) + 32;\n// defining global variable with ac import\nflow.set('aci_id',\"ns=\"+ ns+ \";i=\"+i);\n\n// reading SNO of Zone2 TCN2 50295- 50269 (SNO/value) = 26 is being offset from UMC toEnergy /value\nid_value = flow.get(\"SNO_id\");\npart = id_value.split(\";\");\npart_tmp = part[1].split(\"=\");\ni = Number(part_tmp[1]) + 26;\nflow.set('SNO_id',\"ns=\"+ ns+ \";i=\"+i);\n\n\n//exporting everything for debuging\n\nmsg.temp_id_mvch1 = flow.get(\"temp_id_mvch1\");\nmsg.temp_id_mvch2 = flow.get(\"temp_id_mvch2\");\nmsg.L1_id = flow.get(\"L1_id\");\nmsg.SNO_id = flow.get(\"SNO_id\");\n\nmsg.osp_id = flow.get(\"osp_id\");\nmsg.cmd_id = flow.get(\"cmd_id\");\nmsg.cmd_id = flow.get(\"RE_id\");\nmsg.aci_id = flow.get(\"aci_id\");\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 550,
        "y": 80,
        "wires": [
            [
                "b9527564bb86d79c"
            ]
        ]
    },
    {
        "id": "70ea5289614eb08f",
        "type": "OPCUA-IIoT-Inject",
        "z": "cef6e0716e26e027",
        "injectType": "read",
        "payload": "",
        "payloadType": "date",
        "topic": "",
        "repeat": "30",
        "crontab": "",
        "once": true,
        "startDelay": "60",
        "name": "Read temp Chan 2",
        "addressSpaceItems": [
            {
                "name": "TempChan2",
                "nodeId": "",
                "datatypeName": ""
            }
        ],
        "x": 160,
        "y": 280,
        "wires": [
            [
                "7b5c07e3d317b7fa"
            ]
        ]
    },
    {
        "id": "7b5c07e3d317b7fa",
        "type": "change",
        "z": "cef6e0716e26e027",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload.addressSpaceItems[0].nodeId",
                "pt": "msg",
                "to": "temp_id_mvch1",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "payload.addressSpaceItems[1].nodeId",
                "pt": "msg",
                "to": "temp_id_mvch2",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "payload.addressSpaceItems[2].nodeId",
                "pt": "msg",
                "to": "L1_id",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "payload.addressSpaceItems[3].nodeId",
                "pt": "msg",
                "to": "SNO_id",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "payload.addressSpaceItems[4].nodeId",
                "pt": "msg",
                "to": "osp_id",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "payload.addressSpaceItems[5].nodeId",
                "pt": "msg",
                "to": "cmd_id",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "payload.addressSpaceItems[6].nodeId",
                "pt": "msg",
                "to": "RE_id",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "payload.addressSpaceItems[7].nodeId",
                "pt": "msg",
                "to": "aci_id",
                "tot": "flow"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 360,
        "y": 260,
        "wires": [
            [
                "026fdb9c13b34e98"
            ]
        ]
    },
    {
        "id": "026fdb9c13b34e98",
        "type": "OPCUA-IIoT-Read",
        "z": "cef6e0716e26e027",
        "attributeId": "13",
        "maxAge": 1,
        "depth": 1,
        "connector": "041396811b8c7ab1",
        "name": "Read Value",
        "justValue": true,
        "showStatusActivities": false,
        "showErrors": false,
        "parseStrings": false,
        "historyDays": "",
        "x": 550,
        "y": 280,
        "wires": [
            [
                "71814333c42f01ef",
                "e31b530071bdd3d9"
            ]
        ]
    },
    {
        "id": "71814333c42f01ef",
        "type": "debug",
        "z": "cef6e0716e26e027",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 790,
        "y": 280,
        "wires": []
    },
    {
        "id": "49b7815078264a14",
        "type": "function",
        "z": "cef6e0716e26e027",
        "name": "Array1",
        "func": "msg.payload.value = msg.payload.value[2].value.value;\n\n\n\n\n\nreturn msg\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 670,
        "y": 400,
        "wires": [
            []
        ]
    },
    {
        "id": "393a56951f9ece37",
        "type": "change",
        "z": "cef6e0716e26e027",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "a1",
                "pt": "global",
                "to": "payload.value",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 730,
        "y": 460,
        "wires": [
            []
        ]
    },
    {
        "id": "acd8b058efa915d9",
        "type": "debug",
        "z": "cef6e0716e26e027",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 950,
        "y": 460,
        "wires": []
    },
    {
        "id": "c03422c0e26e5dce",
        "type": "function",
        "z": "cef6e0716e26e027",
        "name": "",
        "func": "let combined = \"\" // Define combined as a string \nfor (let i = 0 ; i < msg.payload.length; i++) { // each array element\n combined += Math.abs(msg.payload[i]) //append it to the string\n}\nmsg.payload = combined\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 680,
        "y": 580,
        "wires": [
            [
                "acd8b058efa915d9"
            ]
        ]
    },
    {
        "id": "8cc4e9a9d7e82638",
        "type": "inject",
        "z": "cef6e0716e26e027",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "cells",
                "v": "Tabellenblatt1",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[1,2,3,4]",
        "payloadType": "json",
        "x": 240,
        "y": 540,
        "wires": [
            []
        ]
    },
    {
        "id": "d983f2de5c92cc9b",
        "type": "change",
        "z": "cef6e0716e26e027",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{msg.payload.mvch2, msg.payload.mvch1,\t }\t",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 240,
        "y": 440,
        "wires": [
            [
                "c03422c0e26e5dce"
            ]
        ]
    },
    {
        "id": "e31b530071bdd3d9",
        "type": "change",
        "z": "cef6e0716e26e027",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "timestamp",
                "pt": "msg",
                "to": "",
                "tot": "date"
            },
            {
                "t": "set",
                "p": "temp_id_mvch1_value",
                "pt": "flow",
                "to": "payload.value.0.value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.mvch1",
                "pt": "msg",
                "to": "payload.value.0.value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "temp_id_mvch2_value",
                "pt": "flow",
                "to": "payload.value.1.value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.mvch2",
                "pt": "msg",
                "to": "payload.value.1.value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "L1_id_value",
                "pt": "flow",
                "to": "payload.value[2].value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.L1_id0",
                "pt": "msg",
                "to": "payload.value[2].value.value[0]",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.L1_id1",
                "pt": "msg",
                "to": "payload.value[2].value.value[1]",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "SNO_id_value",
                "pt": "flow",
                "to": "payload.value.3.value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.SNO_id",
                "pt": "msg",
                "to": "payload.value.3.value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "cmd_id_value",
                "pt": "flow",
                "to": "payload.value.4.value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.cmd_id",
                "pt": "msg",
                "to": "payload.value.4.value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "osp_id_value",
                "pt": "flow",
                "to": "payload.value.5.value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.osp_id",
                "pt": "msg",
                "to": "payload.value.5.value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "RE_id_value",
                "pt": "flow",
                "to": "payload.value.6.value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.RE_id",
                "pt": "msg",
                "to": "payload.value.6.value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.aci_id",
                "pt": "flow",
                "to": "payload.value.7.value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.aci_id",
                "pt": "msg",
                "to": "payload.value.7.value.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.aci_id0",
                "pt": "msg",
                "to": "payload.value[7].value.value[0]",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.aci_id1",
                "pt": "msg",
                "to": "payload.value[7].value.value[3]",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload.RTime",
                "pt": "msg",
                "to": "RTime",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "msg.payload.value[9].value.value",
                "pt": "msg",
                "to": "Too expensive",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 150,
        "y": 380,
        "wires": [
            [
                "d983f2de5c92cc9b"
            ]
        ]
    },
    {
        "id": "041396811b8c7ab1",
        "type": "OPCUA-IIoT-Connector",
        "discoveryUrl": "",
        "endpoint": "opc.tcp://localhost:4840",
        "endpointMustExist": false,
        "keepSessionAlive": true,
        "loginEnabled": true,
        "name": "LOCAL SERVER",
        "showErrors": false,
        "securityPolicy": "None",
        "securityMode": "None",
        "individualCerts": false,
        "publicCertificateFile": "",
        "privateKeyFile": "",
        "defaultSecureTokenLifetime": "",
        "autoSelectRightEndpoint": false,
        "strategyMaxRetry": "",
        "strategyInitialDelay": "",
        "strategyMaxDelay": "",
        "strategyRandomisationFactor": "",
        "requestedSessionTimeout": "",
        "connectionStartDelay": "",
        "reconnectDelay": "",
        "maxBadSessionRequests": "10"
    }
]

```

haplc2000  
 ![my issues 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/c/ecc7519f607eb26aa916279c9349b43de26c127d.jpeg)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [5 August 2024 15:13 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/2 "2024-08-05T15:13:02Z")

</div>

Sharing data as an image will not help people help you, if you shared as text in correct format you may find more help.

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path/value for any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

Also make sure you post the info correctly

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [5 August 2024 15:18 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/3 "2024-08-05T15:18:34Z")

</div>

Hello @haplc2000, welcome to the forum.

You have an array of minus ones, but you want to end up with "1111". I am assuming that you always want to take the absolute value of the input.

A function node is probably the easiest (and easiest to understand) method:

```auto
let combined = "" // Define combined as a string 
for (let i = 0 ; i < msg.payload.length; i++) { // each array element
    combined += Math.abs(msg.payload[i]) //append it to the string
}
msg.payload = combined
return msg;

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/1/b144ed35abdd1107ae52f4ef043dcbe80d277d23.png)

---

<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 August 2024 16:23 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/4 "2024-08-05T16:23:05Z")

</div>

Reading between the lines, you are reading 4 values/bools from Modbus and want to generate a single `WORD` (int16) value so that is can be passed to an OPCUA node?

Is that correct? close?

1st, copy the data coming out of the Modbus node (use the `Copy Value` as @E1cid has shown above) and paste it into a reply

2nd, tell me what the value _SHOULD_ be for the data you are getting from Modbus - then I can show you how to generate an 16 bit WORD from it using `buffer-parser`

---

<div class="post-metadata">

**Author:** ![haplc2000](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@haplc2000](https://discourse.nodered.org/u/haplc2000)\
**Post date:** [5 August 2024 17:12 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/5 "2024-08-05T17:12:27Z")

</div>

Thanks  
I have pasted the code. Hope this is how you would like to see the code?

---

<div class="post-metadata">

**Author:** ![haplc2000](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@haplc2000](https://discourse.nodered.org/u/haplc2000)\
**Post date:** [5 August 2024 17:13 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/6 "2024-08-05T17:13:23Z")

</div>

Thanks  
I am getting the data in the format: object 1: 1  
OBject 2: 1  
Object 3: 1  
Object 4: 1

I would like to have output as 1111

Thanks  
I have pasted the code. Hope this is how you would like to see the code?

---

<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 August 2024 17:15 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/7 "2024-08-05T17:15:08Z")

</div>

> [@haplc2000](#):
>
> I have pasted the code. Hope this is how you would like to see the code?

No. Please use the "Copy Value" button as @E1cid described

> [@E1cid](#):
>
> ![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

Also, please make sure it is the data that comes out of the Modbus node (before you do any processing)

---

<div class="post-metadata">

**Author:** ![haplc2000](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@haplc2000](https://discourse.nodered.org/u/haplc2000)\
**Post date:** [5 August 2024 17:19 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/8 "2024-08-05T17:19:47Z")

</div>

Many thanks jbudd

With inject and four values {1,1,1,1}, it is working perfectly fine.

However my data from is coming from a array in the form: "payload.aci\_id" which I am reading from "payload.value.7.value.value. "

Then "payload.aci\_id" is consisting of four objects which i am reading by using :

```auto
payload.value[7].value.value[0]
payload.value[7].value.value[1]
payload.value[7].value.value[2]
payload.value[7].value.value[3]

```

Could you please help me in writing code to use "combine" command with these four variables:  
ting of four objects which i am reading by using :

```auto
payload.value[7].value.value[0]
payload.value[7].value.value[1]
payload.value[7].value.value[2]
payload.value[7].value.value[3]

```

---

<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 August 2024 17:21 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/9 "2024-08-05T17:21:54Z")

</div>

> [@haplc2000](#):
>
> Could you please help me in writing code to use "combine" command with these four variables:  
> ting of four objects which i am reading by using :

You MUST provide useable data to avoid confustion.

To provide usable data, please use the correct "Copy Value" button.

> [@Steve-Mcl](#):
>
> Please use the "Copy Value" button as @E1cid described
> 
> > [@E1cid](#):
> >
> > ![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

---

<div class="post-metadata">

**Author:** ![haplc2000](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@haplc2000](https://discourse.nodered.org/u/haplc2000)\
**Post date:** [5 August 2024 17:31 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/10 "2024-08-05T17:31:00Z")

</div>

Here is the value of array which is coming from Modbus:  
{"dataType":"Int16","arrayType":"Array","value":{"0":-1,"1":-1,"2":-1,"3":-1}}  
NOte: these values are coming from array:  
payload.value[2].value.value

I have ensured that the values are coming from Modbus.  
To ensure: I have used this variable: payload.value[2].value.value[0]  
-1  
payload.value[2].value.value[1]  
-1  
payload.value[2].value.value[2]  
-1  
payload.value[2].value.value[0]  
-1

---

<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 August 2024 17:34 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/11 "2024-08-05T17:34:33Z")

</div>

> [@haplc2000](#):
>
> Here is the value of array which is coming from Modbus:

I dont see any Modbus devices in your original flow and that data looks nothing like the data I have seen from any Modbus nodes i have used.

> [@haplc2000](#):
>
> {"dataType":"Int16","arrayType":"Array","value":{"0":-1,"1":-1,"2":-1,"3":-1}}  
> NOte: these values are coming from array:  
> payload.value[2].value.value

Then PLEASE copy the `payload` in its entierty - using the `Copy Value` on the `payload` property.

Also, please use a `</>` code block to make data readable and usable.

Lastly, your values are all `-1` which suggests they are either boolean `true` (as in `c` TRUE) or they are signed integers.

Can you clarify these please?

EDIT

also, you state you wanted a "single word" do you mean

1. A 16 bit integer [WORD](https://en.wikipedia.org/wiki/Word_(computer_architecture)) value
2. The values **concatenated** as a string

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [5 August 2024 17:34 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/12 "2024-08-05T17:34:41Z")

</div>

I'm only scanning the replies on my phone but it looks like you have posted three different versions of the data but you have not used a debug node to obtain and post the actual values in a format we can use.

I think @Steve-Mcl and @E1cid have both shown you what we need to see.

---

<div class="post-metadata">

**Author:** ![haplc2000](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@haplc2000](https://discourse.nodered.org/u/haplc2000)\
**Post date:** [5 August 2024 17:41 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/13 "2024-08-05T17:41:34Z")

</div>

Here is the value of payload:

```auto
{"payload":1722599750410,"payloadType":"read","value":[{"value":{"dataType":"Int16","arrayType":"Scalar","value":291},"statusCode":{"value":0},"sourceTimestamp":"2024-08-02T11:55:51.528Z","sourcePicoseconds":424000000,"serverTimestamp":"2024-08-02T11:55:51.528Z","serverPicoseconds":420000000},{"value":{"dataType":"Int16","arrayType":"Scalar","value":299},"statusCode":{"value":0},"sourceTimestamp":"2024-08-02T11:55:51.552Z","sourcePicoseconds":403000000,"serverTimestamp":"2024-08-02T11:55:51.552Z","serverPicoseconds":399000000},{"value":{"dataType":"Int16","arrayType":"Array","value":{"0":-1,"1":-1,"2":-1,"3":-1}},"statusCode":{"value":0},"sourceTimestamp":"2024-08-02T11:55:52.104Z","sourcePicoseconds":80000000,"serverTimestamp":"2024-08-02T11:55:52.104Z","serverPicoseconds":76000000},{"value":{"dataType":"Int16","arrayType":"Scalar","value":12336},"statusCode":{"value":0},"sourceTimestamp":"2024-08-02T11:55:52.127Z","sourcePicoseconds":857000000,"serverTimestamp":"2024-08-02T11:55:52.127Z","serverPicoseconds":852000000},{"value":{"dataType":"Boolean","arrayType":"Scalar","value":false},"statusCode":{"value":0},"sourceTimestamp":"2024-08-02T11:55:52.132Z","sourcePicoseconds":646000000,"serverTimestamp":"2024-08-02T11:55:52.132Z","serverPicoseconds":643000000},{"value":{"dataType":"Boolean","arrayType":"Scalar","value":false},"statusCode":{"value":0},"sourceTimestamp":"2024-08-02T11:55:52.136Z","sourcePicoseconds":758000000,"serverTimestamp":"2024-08-02T11:55:52.136Z","serverPicoseconds":755000000},{"value":{"dataType":"Boolean","arrayType":"Scalar","value":true},"statusCode":{"value":0},"sourceTimestamp":"2024-08-02T11:55:52.141Z","sourcePicoseconds":229000000,"serverTimestamp":"2024-08-02T11:55:52.141Z","serverPicoseconds":225000000},{"value":{"dataType":"Int16","arrayType":"Array","value":{"0":0,"1":0,"2":0,"3":5}},"statusCode":{"value":0},"sourceTimestamp":"2024-08-02T11:55:52.685Z","sourcePicoseconds":159000000,"serverTimestamp":"2024-08-02T11:55:52.685Z","serverPicoseconds":156000000}],"nodetype":"read","injectType":"read","addressSpaceItems":[{"name":"TempChan2","nodeId":"ns=0;i=50343","datatypeName":""},{"nodeId":"ns=0;i=50349"},{"nodeId":"ns=0;i=50601"},{"nodeId":"ns=0;i=50640"},{"nodeId":"ns=0;i=50722"},{"nodeId":"ns=0;i=50723"},{"nodeId":"ns=0;i=50724"},{"nodeId":"ns=0;i=50547"}],"manualInject":true,"readtype":"VariableValue","attributeId":13,"justValue":true}

```

_ADMIN EDIT: Surrounded code with triple ````` backticks code fence_

It is for sure Modbus..please see fucntion "find node ids.": I have not used classical modbus server.

Output: yes, should be single unsigned integer

Please note that all the four objects are unsigned integer

---

<div class="post-metadata">

**Author:** ![haplc2000](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@haplc2000](https://discourse.nodered.org/u/haplc2000)\
**Post date:** [5 August 2024 17:45 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/14 "2024-08-05T17:45:22Z")

</div>

Hmm..I am trying to send what is needed and and in the required form. But being new, in both Node Red and in this forum..it is challenging.  
I think, your answer is very much near to what I am looking for. However could not figure out how to replace a fixed array with the array consisting of four objects coming from one array

---

<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 August 2024 17:56 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/15 "2024-08-05T17:56:20Z")

</div>

> [@haplc2000](#):
>
> It is for sure Modbus..please see fucntion "find node ids.": I have not used classical modbus server.

That data is coming from OPCUA. There may be a modbus device behind your OPCUA server but this data is not what we expect when dealing with Modbus in Node-RED. Modbus outputs 16 bit values or boolean values (depending on the Modbus FN CODE)

> [@haplc2000](#):
>
> Output: yes, should be single unsigned integer

So, your data contains 4 values of `-1` what should the answer be? The sum? A bitwise OR? Multiplied together?

What if the data had `12, 34, 56, -77` - what would you expect the output to be?

In short, please clarify what these -1 values are and how you expect to compute the value?

---

<div class="post-metadata">

**Author:** ![haplc2000](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@haplc2000](https://discourse.nodered.org/u/haplc2000)\
**Post date:** [5 August 2024 18:15 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/16 "2024-08-05T18:15:37Z")

</div>

What if the data had `12, 34, 56, -77` - what would you expect the output to be?

In this case, output should be  
123456-77

---

<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 August 2024 18:37 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/17 "2024-08-05T18:37:22Z")

</div>

This statement ↓

> [@haplc2000](#):
>
> Output: yes, should be single unsigned integer

contradicts this statement ↓

> [@haplc2000](#):
>
> In this case, output should be  
> 123456-77

Anyhow, going from your last statement, this is just string concatenation and this can be done without any code using the spit and join nodes.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/0/9029a28d6c3a3f9310b1adabf0d89d241f586801.png)

Demo flow - use CTRL-I to import

```auto
[{"id":"ac1db709abc5e164","type":"inject","z":"a852e4845e0e51a4","name":"-1 -1 -1 -1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"payload\":1722599750410,\"payloadType\":\"read\",\"value\":[{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Scalar\",\"value\":291},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:51.528Z\",\"sourcePicoseconds\":424000000,\"serverTimestamp\":\"2024-08-02T11:55:51.528Z\",\"serverPicoseconds\":420000000},{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Scalar\",\"value\":299},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:51.552Z\",\"sourcePicoseconds\":403000000,\"serverTimestamp\":\"2024-08-02T11:55:51.552Z\",\"serverPicoseconds\":399000000},{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Array\",\"value\":{\"0\":-1,\"1\":-1,\"2\":-1,\"3\":-1}},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.104Z\",\"sourcePicoseconds\":80000000,\"serverTimestamp\":\"2024-08-02T11:55:52.104Z\",\"serverPicoseconds\":76000000},{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Scalar\",\"value\":12336},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.127Z\",\"sourcePicoseconds\":857000000,\"serverTimestamp\":\"2024-08-02T11:55:52.127Z\",\"serverPicoseconds\":852000000},{\"value\":{\"dataType\":\"Boolean\",\"arrayType\":\"Scalar\",\"value\":false},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.132Z\",\"sourcePicoseconds\":646000000,\"serverTimestamp\":\"2024-08-02T11:55:52.132Z\",\"serverPicoseconds\":643000000},{\"value\":{\"dataType\":\"Boolean\",\"arrayType\":\"Scalar\",\"value\":false},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.136Z\",\"sourcePicoseconds\":758000000,\"serverTimestamp\":\"2024-08-02T11:55:52.136Z\",\"serverPicoseconds\":755000000},{\"value\":{\"dataType\":\"Boolean\",\"arrayType\":\"Scalar\",\"value\":true},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.141Z\",\"sourcePicoseconds\":229000000,\"serverTimestamp\":\"2024-08-02T11:55:52.141Z\",\"serverPicoseconds\":225000000},{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Array\",\"value\":{\"0\":0,\"1\":0,\"2\":0,\"3\":5}},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.685Z\",\"sourcePicoseconds\":159000000,\"serverTimestamp\":\"2024-08-02T11:55:52.685Z\",\"serverPicoseconds\":156000000}],\"nodetype\":\"read\",\"injectType\":\"read\",\"addressSpaceItems\":[{\"name\":\"TempChan2\",\"nodeId\":\"ns=0;i=50343\",\"datatypeName\":\"\"},{\"nodeId\":\"ns=0;i=50349\"},{\"nodeId\":\"ns=0;i=50601\"},{\"nodeId\":\"ns=0;i=50640\"},{\"nodeId\":\"ns=0;i=50722\"},{\"nodeId\":\"ns=0;i=50723\"},{\"nodeId\":\"ns=0;i=50724\"},{\"nodeId\":\"ns=0;i=50547\"}],\"manualInject\":true,\"readtype\":\"VariableValue\",\"attributeId\":13,\"justValue\":true}","payloadType":"json","x":1540,"y":160,"wires":[["97f0eb409dd378b6"]]},{"id":"ca2272dffd837ca8","type":"join","z":"a852e4845e0e51a4","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","useparts":false,"accumulate":false,"timeout":"0.1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1710,"y":280,"wires":[["bc620b9e6f1f3587"]]},{"id":"79d40574d62c80e3","type":"split","z":"a852e4845e0e51a4","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","property":"payload","x":1540,"y":280,"wires":[["ca2272dffd837ca8"]]},{"id":"bc620b9e6f1f3587","type":"debug","z":"a852e4845e0e51a4","name":"debug 190","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1870,"y":280,"wires":[]},{"id":"97f0eb409dd378b6","type":"change","z":"a852e4845e0e51a4","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.value[2].value.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1840,"y":180,"wires":[["79d40574d62c80e3"]]},{"id":"c3a783d3cf1b8684","type":"inject","z":"a852e4845e0e51a4","name":"12, 34, 45, -77","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"payload\":1722599750410,\"payloadType\":\"read\",\"value\":[{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Scalar\",\"value\":291},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:51.528Z\",\"sourcePicoseconds\":424000000,\"serverTimestamp\":\"2024-08-02T11:55:51.528Z\",\"serverPicoseconds\":420000000},{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Scalar\",\"value\":299},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:51.552Z\",\"sourcePicoseconds\":403000000,\"serverTimestamp\":\"2024-08-02T11:55:51.552Z\",\"serverPicoseconds\":399000000},{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Array\",\"value\":{\"0\":12,\"1\":34,\"2\":56,\"3\":-77}},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.104Z\",\"sourcePicoseconds\":80000000,\"serverTimestamp\":\"2024-08-02T11:55:52.104Z\",\"serverPicoseconds\":76000000},{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Scalar\",\"value\":12336},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.127Z\",\"sourcePicoseconds\":857000000,\"serverTimestamp\":\"2024-08-02T11:55:52.127Z\",\"serverPicoseconds\":852000000},{\"value\":{\"dataType\":\"Boolean\",\"arrayType\":\"Scalar\",\"value\":false},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.132Z\",\"sourcePicoseconds\":646000000,\"serverTimestamp\":\"2024-08-02T11:55:52.132Z\",\"serverPicoseconds\":643000000},{\"value\":{\"dataType\":\"Boolean\",\"arrayType\":\"Scalar\",\"value\":false},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.136Z\",\"sourcePicoseconds\":758000000,\"serverTimestamp\":\"2024-08-02T11:55:52.136Z\",\"serverPicoseconds\":755000000},{\"value\":{\"dataType\":\"Boolean\",\"arrayType\":\"Scalar\",\"value\":true},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.141Z\",\"sourcePicoseconds\":229000000,\"serverTimestamp\":\"2024-08-02T11:55:52.141Z\",\"serverPicoseconds\":225000000},{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Array\",\"value\":{\"0\":0,\"1\":0,\"2\":0,\"3\":5}},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.685Z\",\"sourcePicoseconds\":159000000,\"serverTimestamp\":\"2024-08-02T11:55:52.685Z\",\"serverPicoseconds\":156000000}],\"nodetype\":\"read\",\"injectType\":\"read\",\"addressSpaceItems\":[{\"name\":\"TempChan2\",\"nodeId\":\"ns=0;i=50343\",\"datatypeName\":\"\"},{\"nodeId\":\"ns=0;i=50349\"},{\"nodeId\":\"ns=0;i=50601\"},{\"nodeId\":\"ns=0;i=50640\"},{\"nodeId\":\"ns=0;i=50722\"},{\"nodeId\":\"ns=0;i=50723\"},{\"nodeId\":\"ns=0;i=50724\"},{\"nodeId\":\"ns=0;i=50547\"}],\"manualInject\":true,\"readtype\":\"VariableValue\",\"attributeId\":13,\"justValue\":true}","payloadType":"json","x":1530,"y":200,"wires":[["97f0eb409dd378b6"]]}]

```

---

<div class="post-metadata">

**Author:** ![haplc2000](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@haplc2000](https://discourse.nodered.org/u/haplc2000)\
**Post date:** [5 August 2024 18:49 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/18 "2024-08-05T18:49:42Z")

</div>

Thanks

However, this is not what I am looking for. I have to use the variables coming from payloads. Not fixed numbers.

Also, the code is giving error while importing.

Best regards

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [5 August 2024 19:08 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/19 "2024-08-05T19:08:15Z")

</div>

The import from @Steve-Mcl worked fine for me

If you require to join/concat the object values in indices 2 and 7 no matter their length then use a automatic join. Use msg.parts.type to change from `object` to `string`, and msg.parts.ch to define the join string.

This example converts both the objects from indices 2 and 7 into strings

```auto
[{"id":"9a35d547d76baf73","type":"inject","z":"613df62afc8a16bf","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"payload\":1722599750410,\"payloadType\":\"read\",\"value\":[{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Scalar\",\"value\":291},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:51.528Z\",\"sourcePicoseconds\":424000000,\"serverTimestamp\":\"2024-08-02T11:55:51.528Z\",\"serverPicoseconds\":420000000},{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Scalar\",\"value\":299},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:51.552Z\",\"sourcePicoseconds\":403000000,\"serverTimestamp\":\"2024-08-02T11:55:51.552Z\",\"serverPicoseconds\":399000000},{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Array\",\"value\":{\"0\":-1,\"1\":-1,\"2\":-1,\"3\":-1}},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.104Z\",\"sourcePicoseconds\":80000000,\"serverTimestamp\":\"2024-08-02T11:55:52.104Z\",\"serverPicoseconds\":76000000},{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Scalar\",\"value\":12336},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.127Z\",\"sourcePicoseconds\":857000000,\"serverTimestamp\":\"2024-08-02T11:55:52.127Z\",\"serverPicoseconds\":852000000},{\"value\":{\"dataType\":\"Boolean\",\"arrayType\":\"Scalar\",\"value\":false},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.132Z\",\"sourcePicoseconds\":646000000,\"serverTimestamp\":\"2024-08-02T11:55:52.132Z\",\"serverPicoseconds\":643000000},{\"value\":{\"dataType\":\"Boolean\",\"arrayType\":\"Scalar\",\"value\":false},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.136Z\",\"sourcePicoseconds\":758000000,\"serverTimestamp\":\"2024-08-02T11:55:52.136Z\",\"serverPicoseconds\":755000000},{\"value\":{\"dataType\":\"Boolean\",\"arrayType\":\"Scalar\",\"value\":true},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.141Z\",\"sourcePicoseconds\":229000000,\"serverTimestamp\":\"2024-08-02T11:55:52.141Z\",\"serverPicoseconds\":225000000},{\"value\":{\"dataType\":\"Int16\",\"arrayType\":\"Array\",\"value\":{\"0\":0,\"1\":0,\"2\":0,\"3\":5}},\"statusCode\":{\"value\":0},\"sourceTimestamp\":\"2024-08-02T11:55:52.685Z\",\"sourcePicoseconds\":159000000,\"serverTimestamp\":\"2024-08-02T11:55:52.685Z\",\"serverPicoseconds\":156000000}],\"nodetype\":\"read\",\"injectType\":\"read\",\"addressSpaceItems\":[{\"name\":\"TempChan2\",\"nodeId\":\"ns=0;i=50343\",\"datatypeName\":\"\"},{\"nodeId\":\"ns=0;i=50349\"},{\"nodeId\":\"ns=0;i=50601\"},{\"nodeId\":\"ns=0;i=50640\"},{\"nodeId\":\"ns=0;i=50722\"},{\"nodeId\":\"ns=0;i=50723\"},{\"nodeId\":\"ns=0;i=50724\"},{\"nodeId\":\"ns=0;i=50547\"}],\"manualInject\":true,\"readtype\":\"VariableValue\",\"attributeId\":13,\"justValue\":true}","payloadType":"json","x":130,"y":60,"wires":[["96dc0abe90937934"]]},{"id":"96dc0abe90937934","type":"split","z":"613df62afc8a16bf","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","property":"payload.value","x":270,"y":60,"wires":[["6f3d07ffeb55167a"]]},{"id":"6f3d07ffeb55167a","type":"switch","z":"613df62afc8a16bf","name":"","property":"payload.value.value.arrayType","propertyType":"msg","rules":[{"t":"eq","v":"Array","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":210,"y":120,"wires":[["79d40574d62c80e3"],["2605ac3cfa52d6e5"]]},{"id":"79d40574d62c80e3","type":"split","z":"613df62afc8a16bf","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","property":"payload.value.value.value","x":370,"y":120,"wires":[["8b3b64c3911d57f6"]]},{"id":"2605ac3cfa52d6e5","type":"join","z":"613df62afc8a16bf","name":"","mode":"auto","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","useparts":false,"accumulate":"false","timeout":"","count":"","reduceRight":false,"x":270,"y":180,"wires":[["bc620b9e6f1f3587"]]},{"id":"8b3b64c3911d57f6","type":"change","z":"613df62afc8a16bf","name":"","rules":[{"t":"set","p":"parts.type","pt":"msg","to":"string","tot":"str"},{"t":"set","p":"parts.ch","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":120,"wires":[["ca2272dffd837ca8"]]},{"id":"ca2272dffd837ca8","type":"join","z":"613df62afc8a16bf","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","useparts":false,"accumulate":false,"timeout":"0.1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":670,"y":120,"wires":[["2605ac3cfa52d6e5"]]},{"id":"bc620b9e6f1f3587","type":"debug","z":"613df62afc8a16bf","name":"debug 190","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":450,"y":180,"wires":[]}]

```

Output

```auto
{
    "payload": 1722599750410,
    "payloadType": "read",
    "value": [
        {
            "value": {
                "dataType": "Int16",
                "arrayType": "Scalar",
                "value": 291
            },
            "statusCode": {
                "value": 0
            },
            "sourceTimestamp": "2024-08-02T11:55:51.528Z",
            "sourcePicoseconds": 424000000,
            "serverTimestamp": "2024-08-02T11:55:51.528Z",
            "serverPicoseconds": 420000000
        },
        {
            "value": {
                "dataType": "Int16",
                "arrayType": "Scalar",
                "value": 299
            },
            "statusCode": {
                "value": 0
            },
            "sourceTimestamp": "2024-08-02T11:55:51.552Z",
            "sourcePicoseconds": 403000000,
            "serverTimestamp": "2024-08-02T11:55:51.552Z",
            "serverPicoseconds": 399000000
        },
        {
            "value": {
                "dataType": "Int16",
                "arrayType": "Array",
                "value": "-1-1-1-1"
            },
            "statusCode": {
                "value": 0
            },
            "sourceTimestamp": "2024-08-02T11:55:52.104Z",
            "sourcePicoseconds": 80000000,
            "serverTimestamp": "2024-08-02T11:55:52.104Z",
            "serverPicoseconds": 76000000
        },
        {
            "value": {
                "dataType": "Int16",
                "arrayType": "Scalar",
                "value": 12336
            },
            "statusCode": {
                "value": 0
            },
            "sourceTimestamp": "2024-08-02T11:55:52.127Z",
            "sourcePicoseconds": 857000000,
            "serverTimestamp": "2024-08-02T11:55:52.127Z",
            "serverPicoseconds": 852000000
        },
        {
            "value": {
                "dataType": "Boolean",
                "arrayType": "Scalar",
                "value": false
            },
            "statusCode": {
                "value": 0
            },
            "sourceTimestamp": "2024-08-02T11:55:52.132Z",
            "sourcePicoseconds": 646000000,
            "serverTimestamp": "2024-08-02T11:55:52.132Z",
            "serverPicoseconds": 643000000
        },
        {
            "value": {
                "dataType": "Boolean",
                "arrayType": "Scalar",
                "value": false
            },
            "statusCode": {
                "value": 0
            },
            "sourceTimestamp": "2024-08-02T11:55:52.136Z",
            "sourcePicoseconds": 758000000,
            "serverTimestamp": "2024-08-02T11:55:52.136Z",
            "serverPicoseconds": 755000000
        },
        {
            "value": {
                "dataType": "Boolean",
                "arrayType": "Scalar",
                "value": true
            },
            "statusCode": {
                "value": 0
            },
            "sourceTimestamp": "2024-08-02T11:55:52.141Z",
            "sourcePicoseconds": 229000000,
            "serverTimestamp": "2024-08-02T11:55:52.141Z",
            "serverPicoseconds": 225000000
        },
        {
            "value": {
                "dataType": "Int16",
                "arrayType": "Array",
                "value": "0005"
            },
            "statusCode": {
                "value": 0
            },
            "sourceTimestamp": "2024-08-02T11:55:52.685Z",
            "sourcePicoseconds": 159000000,
            "serverTimestamp": "2024-08-02T11:55:52.685Z",
            "serverPicoseconds": 156000000
        }
    ],
    "nodetype": "read",
    "injectType": "read",
    "addressSpaceItems": [
        {
            "name": "TempChan2",
            "nodeId": "ns=0;i=50343",
            "datatypeName": ""
        },
        {
            "nodeId": "ns=0;i=50349"
        },
        {
            "nodeId": "ns=0;i=50601"
        },
        {
            "nodeId": "ns=0;i=50640"
        },
        {
            "nodeId": "ns=0;i=50722"
        },
        {
            "nodeId": "ns=0;i=50723"
        },
        {
            "nodeId": "ns=0;i=50724"
        },
        {
            "nodeId": "ns=0;i=50547"
        }
    ],
    "manualInject": true,
    "readtype": "VariableValue",
    "attributeId": 13,
    "justValue": true
}

```

---

<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 August 2024 19:38 UTC](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003/20 "2024-08-05T19:38:21Z")

</div>

> [@haplc2000](#):
>
> However, this is not what I am looking for. I have to use the variables coming from payloads. Not fixed numbers

I'm not sure if you are trolling or not?

The inject nodes are there purely for demonstration!. I used YOUR DATA so it is EXACTLY the right format. (Add a debug to to output of the inject nodes to confirm!)

You are supposed to remove the injects and attach the flow to your live/real data!

[Next page](https://discourse.nodered.org/t/combining-values-from-an-array-into-a-single-word/90003.md?page=2)
