# SPLIT node - help

**URL:** <https://discourse.nodered.org/t/split-node-help/25006>\
**Category:** General\
**Created:** [17 April 2020 09:52 UTC](https://discourse.nodered.org/t/split-node-help/25006 "2020-04-17T09:52:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 April 2020 09:52 UTC](https://discourse.nodered.org/t/split-node-help/25006/1 "2020-04-17T09:52:15Z")

</div>

Though I am open to alternate nodes to do this.

(Actually I am now thinking this is not the right node for this job, but.....)

I have a message payload (example) `123`

I want to split it into 3 messages: `1``2` and `3`.

I'm not up on node-red's _asynchronous_ operations, but it may not be needed.

Oh, _Specifications_ for the function:  
3 digits. Numbers.  
Must be 3 numbers long.  
Leading `0` must be sent. (Kinda given if 3 digits)  
A nominal delay between messages being sent out.

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [17 April 2020 10:11 UTC](https://discourse.nodered.org/t/split-node-help/25006/2 "2020-04-17T10:11:08Z")

</div>

With function node maybe like this

```auto
let digits = msg.payload.toString().split('');
let realDigits = digits.map(Number)

function sendOut(digit){
    node.send({payload:digit})
}

realDigits.forEach(sendOut)

```

And then add delay node after function node and adjust the delay between messages as needed.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 April 2020 10:14 UTC](https://discourse.nodered.org/t/split-node-help/25006/3 "2020-04-17T10:14:59Z")

</div>

I'm happy with that.

I was messing around with:

```auto
var y = 0;
var z = 0;
var x = msg.payload;

y = parseInt(x / 100);
msg.payload = y;
node.send(msg);
x = x - (y * 100);

msg.payload = x

node.send(msg);

msg.payload = "test";

return msg;

```

Yeah, the `test` isn't needed, but just to see progress.

So I was:  
int(/100) -- send result  
modify  
int(/10) -- send result  
modify  
send last digit.

But yours seems nicer.

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 May 2020 10:15 UTC](https://discourse.nodered.org/t/split-node-help/25006/4 "2020-05-01T10:15:08Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
