Open minhhn0205 opened 4 years ago
I am sorry to have kept you waiting.
I can't identify the cause. So I write an example flow using array-loop node. Cloud you check this flow and your flow, especially array-loop node's properties?
[{"id":"58862348.2eaadc","type":"inject","z":"cacee7e4.aa35c8","name":"msg.payload = \"A, B, C, D, E\"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"A, B, C, D, E","payloadType":"str","x":160,"y":740,"wires":[["914634da.5710d8"]]},{"id":"bddc6bc4.32a698","type":"debug","z":"cacee7e4.aa35c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":820,"wires":[]},{"id":"6553aa43.9b0814","type":"array-loop","z":"cacee7e4.aa35c8","name":"array-loop","key":"al6553aa439b0814","keyType":"msg","reset":false,"resetValue":"value-null","array":"alphabets","arrayType":"msg","x":560,"y":820,"wires":[["bddc6bc4.32a698"],["78dab0ce.5f1fb"]]},{"id":"914634da.5710d8","type":"change","z":"cacee7e4.aa35c8","name":"split msg.payload and set msg.alphabets","rules":[{"t":"set","p":"alphabets","pt":"msg","to":"$split(msg.payload, \", \")\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":820,"wires":[["6553aa43.9b0814"]]},{"id":"dc5087dc.4d81b8","type":"debug","z":"cacee7e4.aa35c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":960,"wires":[]},{"id":"78dab0ce.5f1fb","type":"delay","z":"cacee7e4.aa35c8","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":420,"y":900,"wires":[["dc5087dc.4d81b8","94fd8e89.56cc1"]]},{"id":"94fd8e89.56cc1","type":"function","z":"cacee7e4.aa35c8","name":"return msg","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":610,"y":900,"wires":[["6553aa43.9b0814"]]}]
I think the OP was asking if there was a way to break out of the loop. I have this problem. If some logic error prevents a loop returning, then the only I can find to reset the count is to change something in the node, deploy, change back, deploy.
For example this alternative node https://flows.nodered.org/node/node-red-contrib-loop allows you to inject a msg.command = "break" which is a much cleaner way of resetting.
I use the array-loop node to browse the array, I tried setting the node to break the array midway but it didn't work. Please tell me! Thanks.
For example, output to value C will break the array and continue to process outside
array-loop