# Questions about some functions

**URL:** <https://discourse.nodered.org/t/questions-about-some-functions/18157>\
**Category:** General\
**Created:** [19 November 2019 18:42 UTC](https://discourse.nodered.org/t/questions-about-some-functions/18157 "2019-11-19T18:42:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hubertus3th](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hubertus3th/32/14421_2.png) [@Hubertus3th](https://discourse.nodered.org/u/Hubertus3th)\
**Post date:** [19 November 2019 18:42 UTC](https://discourse.nodered.org/t/questions-about-some-functions/18157/1 "2019-11-19T18:42:57Z")

</div>

Hey Guys i have some questions about my programming skills. Please don´t delete my post i´m new to programming with java and node red.

```auto
Temp:
[{"id":"1fbb0938.77cf67","type":"function","z":"56d57d0c.f202b4","name":"Temperatur","func":"temp = (((msg.payload[0]&0x0f)<<8) + msg.payload[1]) * 0.0625;\n\nflow.set ('temperatur', temp);\n\nreturn msg;","outputs":1,"noerr":0,"x":610,"y":40,"wires":[["7138349d.c8c46c"]]}]

ChatId Reg.

[{"id":"3fb253ac.49436c","type":"function","z":"56d57d0c.f202b4","name":"chatId registrieren","func":"var registered_chatIDs = flow.get('registered_chatIDs','storeInFile') || [];\n\nmsg.registered_chatID = null;\n\nif (!registered_chatIDs.includes(msg.payload.chatId)){\n \n registered_chatIDs.push(msg.payload.chatId);\n \n msg.registered_chatID = msg.payload.chatId;\n \n flow.set('registered_chatIDs', registered_chatIDs, 'storeInFile');\n}\n\n\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":200,"wires":[["8f1b2c8b.3983a"]]}]

ChatId lös.

[{"id":"86f98961.dbbc88","type":"function","z":"56d57d0c.f202b4","name":"chatId lös","func":"var registered_chatIDs = flow.get('registered_chatIDs','storeInFile') || [];\n\nfor( var i = 0; i < registered_chatIDs.length; i++){ \n if ( registered_chatIDs[i] === msg.payload.chatId) {\n registered_chatIDs.splice(i, 1); \n }\n msg.registered_chatID = msg.payload.chatId;\n flow.set('registered_chatIDs', registered_chatIDs, 'storeInFile');\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":300,"wires":[["f6057c1b.42ad2"]]}]

Count+1

[{"id":"dee675ee.2eb7c8","type":"function","z":"7fdc0f6d.41cfc","name":"Plus1","func":"var count=global.get('count')||0;\n//var res = global.get(\"counter\");\n//count=res;\ncount+=1;\nglobal.set('count',count);\nmsg.count=count;\n//global.set(\"zahl\",count);\n\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":180,"wires":[["6aa91812.76a308"]]}]

ResCount

[{"id":"c4ac4f73.499d1","type":"function","z":"7fdc0f6d.41cfc","name":"Reset","func":"var reset = global.get(\"count\");\nreset = 0;\nglobal.set(\"count\",reset);\nmsg.count = 0;\n\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":260,"wires":[["6aa91812.76a308"]]}]

Count-1

[{"id":"dd1e9107.4444b","type":"function","z":"7fdc0f6d.41cfc","name":"Minus1","func":"var minus = global.get(\"count\");\nminus = minus -1;\nglobal.set(\"count\",minus);\nmsg.count = minus;\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":320,"wires":[["6aa91812.76a308"]]}]

JoinCOunt

[{"id":"dd285a93.d86cb8","type":"join","z":"1496f29f.83002d","name":"","mode":"custom","build":"array","property":"payload.content","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":690,"y":360,"wires":[["e48c6df4.888be"]]},{"id":"e48c6df4.888be","type":"function","z":"1496f29f.83002d","name":"","func":"var count=context.get('count')||0;\n\nif(msg.payload.content[0] ==\"LS1\" && msg.payload.content[1] ==\"LS2\" )\n{\n count++;\n}\nif(msg.payload.content[0] ==\"LS2\" && msg.payload.content[1] ==\"LS1\" )\n{\n count--;\n}\ncontext.set('count' ,count);\n\nmsg.count = count;\n\nreturn msg;","outputs":1,"noerr":0,"x":830,"y":360,"wires":[["7c322f41.db037","a115bb83.3525a8"]]}]

```

I have also some pages to help to understand.

> **[rdmtc/RedMatic](https://github.com/rdmtc/RedMatic/wiki/Nachrichten-an-Telegram-versenden)**
>
> Node-RED packaged as Addon for the Homematic CCU3 and RaspberryMatic 🤹‍♂️ - rdmtc/RedMatic

> **[codmpm/node-red-contrib-loxone](https://github.com/codmpm/node-red-contrib-loxone/wiki/Anf%C3%A4nger%3A-Installation-RPi%2C-node-red%2C-nodes)**
>
> Connect the Loxone Miniserver to node-red via the Websocket API - codmpm/node-red-contrib-loxone

Greets Hubertus

---

<div class="post-metadata">

**Author:** ![Hubertus3th](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hubertus3th/32/14421_2.png) [@Hubertus3th](https://discourse.nodered.org/u/Hubertus3th)\
**Post date:** [19 November 2019 19:09 UTC](https://discourse.nodered.org/t/questions-about-some-functions/18157/2 "2019-11-19T19:09:06Z")

</div>

Or maybe you can do something like that:

```auto
senttoallchatid:

[{"id":"94336421.675e18","type":"function","z":"91712dad.6ebbf","name":"an chatIDs senden","func":"var registered_chatIDs = flow.get('registered_chatIDs','storeInFile') || [];\n\nvar message_array =[];\n\nregistered_chatIDs.forEach(function(chatId) {\n message_array.push({...msg.payload,'chatId': chatId});\n});\n\nmsg.payload = message_array;\n\nreturn msg;","outputs":1,"noerr":0,"x":630,"y":480,"wires":[["dd5f5232.d99a6","eebc6ca0.8033"]]}]

```

I don´t if this is right

---

<div class="post-metadata">

**Author:** ![Hubertus3th](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hubertus3th/32/14421_2.png) [@Hubertus3th](https://discourse.nodered.org/u/Hubertus3th)\
**Post date:** [19 November 2019 19:47 UTC](https://discourse.nodered.org/t/questions-about-some-functions/18157/3 "2019-11-19T19:47:01Z")

</div>

```auto
[{"id":"d9c4505a.0530b","type":"change","z":"56d57d0c.f202b4","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.chatId","pt":"msg","to":"982716435","tot":"str"},{"t":"set","p":"payload.type","pt":"msg","to":"message","tot":"str"},{"t":"set","p":"payload.content","pt":"msg","to":"Bitte","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":660,"wires":[["c8930dc3.9c3d8"]]}]

```

Is this right?

---

<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:** [19 November 2019 21:27 UTC](https://discourse.nodered.org/t/questions-about-some-functions/18157/4 "2019-11-19T21:27:32Z")

</div>

Rather than post a number of different flows giving us no clue as to what actual question you are asking it would be better to post just one flow and explain briefly what the flow should do, and what the problem is.
