Hi guys,
I'am trying to do a simple for loop but I can't find a way to return a msg.payload each time it goes through this loop.
var length = msg.payloadSplit.length;
for (i = 0; i < length; i++){
msg.payload = i;
return msg;
}
Thanks
Hi guys,
I'am trying to do a simple for loop but I can't find a way to return a msg.payload each time it goes through this loop.
var length = msg.payloadSplit.length;
for (i = 0; i < length; i++){
msg.payload = i;
return msg;
}
Thanks
Function can only return 1 msg.
If you want to return more, you need to use node.send({payload:xx})
btw are you sure this is correct msg.payloadSplit.length
?
And ofcourse this has all been documented in the documentation.
Thanks a lot for your help, the documentation helped me
Here is what helped me :
var outputMsgs = [];
var words = msg.payload.split(" ");
for (var w in words) {
outputMsgs.push({payload:words[w]});
}
return [ outputMsgs ];
Strictly speaking, is that true?
Would it not be more accurate to say that Functions can return any number of messages using RETURN, but RETURN can only be called ONCE in a Function?
Sorry, feeling very pedantic today.