Incrementing a payload msg and formatting a string

I need to send 1rt 1-1 to a udp node. When I send the msg.payload I need to start the output with 1rt 1-1 and increment the last number by 1 until it gets to 17. Example 1rt 1-1, 1rt 1-2, 1rt 1-3 ..... 1rt 1-17. Once it gets to 17 I need to start the incrementing to 1rt 2-1, 1rt 2-2, 1rt 2-3,...... 1rt 2-17.

This will happen 12 to 13 times.

When I receive the udp stream it comes in like this >2:T1-17,1,64F. I need the format to be 2,1,17,1,64.

The first part.

Well, I guess you could write a bit of Javascript and make things happen.

That depends on how good you are at writing JS code though.

I'm not sure where the this will happen 12 to 13 times comes into it though.

eg code:

//  set up initial values and increment them as needed.
let a = 0;
let b = 1

//  message received.
a = a + 1;
msg = {"payload" : "1rt " + b + "-" + "a"};
//
return msg;

This will work to the point that you would get 1rt 1-x where x just keeps growing.

You will need to build on that so when a == 17 (or more so 18) it loops back and increments b and sets a to 1.

I won't do that for you at this point as I think it may be better you try and see if you can do it.
If you get stuck I may be able to help you - or anyone else here.

The second part:

You are going to have to split that message a lot of times to break it down to those parts.
There is/are nodes that would do it, but I think that you would/may be better off doing it all in one function node - again: depending on how good you are at JS.

I hope that/this helps you.

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