I need to use continue
in nested forEach loops.
I want to skip iteration in this case:
outerLoop: outer_loop3
middleLoop: middle_loop3
innerLoop: inner_loop2
after this case I want to go to next iteration whuch is:
outerLoop: outer_loop4
middleLoop: middle_loop1
innerLoop: inner_loop1
I tried to use goToLabel + counitue commands (and separately also)
But looks like continue command does not work as expected to be.
Please advice
Here’s my example:
{
"Name": "demo-1",
"CreationDate": "2024-2-23",
"Commands": [
{
"Command": "store",
"Target": "fast",
"Value": "!replayspeed",
"Description": ""
},
{
"Command": "executeScript",
"Target": "return [\n {\n \"outer_loop\":\"outer_loop 1\"\n },\n {\n \"outer_loop\":\"outer_loop 2\"\n },\n {\n \"outer_loop\":\"outer_loop 3\"\n },\n {\n \"outer_loop\":\"outer_loop 4\"\n }\n];",
"Value": "outerLoops",
"Description": ""
},
{
"Command": "executeScript",
"Target": "return [\n \"middle_loop1\", \n \"middle_loop2\", \n \"middle_loop3\"\n];",
"Value": "middleLoops",
"Description": ""
},
{
"Command": "executeScript",
"Target": "return [\n {\n \"inner_loop\":\"inner_loop1\"\n },\n {\n \"inner_loop\":\"inner_loop2\"\n }\n];",
"Value": "innerLoops",
"Description": ""
},
{
"Command": "forEach",
"Target": "outerLoops",
"Value": "outerLoop",
"Description": ""
},
{
"Command": "echo",
"Target": "outerLoop: ${outerLoop.outer_loop}",
"Value": "blue",
"Description": ""
},
{
"Command": "forEach",
"Target": "middleLoops",
"Value": "middleLoop",
"Description": ""
},
{
"Command": "echo",
"Target": "middleLoop: ${middleLoop}",
"Value": "green",
"Description": ""
},
{
"Command": "forEach",
"Target": "innerLoops",
"Value": "innerLoop",
"Description": ""
},
{
"Command": "echo",
"Target": "innerLoop: ${innerLoop.inner_loop}",
"Value": "red",
"Description": ""
},
{
"Command": "end",
"Target": "",
"Value": "",
"Description": ""
},
{
"Command": "end",
"Target": "",
"Value": "",
"Description": ""
},
{
"Command": "end",
"Target": "",
"Value": "",
"Description": ""
}
]
}
This output I expect:
[echo] outerLoop: outer_loop1
[echo] middleLoop: middle_loop1
[echo] innerLoop: inner_loop1
[echo] innerLoop: inner_loop2
[echo] middleLoop: middle_loop2
[echo] innerLoop: inner_loop1
[echo] innerLoop: inner_loop2
[echo] middleLoop: middle_loop3
[echo] innerLoop: inner_loop1
[echo] innerLoop: inner_loop2
[echo] outerLoop: outer_loop2
[echo] middleLoop: middle_loop1
[echo] innerLoop: inner_loop1
[echo] innerLoop: inner_loop2
[echo] middleLoop: middle_loop2
[echo] innerLoop: inner_loop1
[echo] innerLoop: inner_loop2
[echo] middleLoop: middle_loop3
[echo] innerLoop: inner_loop1
[echo] innerLoop: inner_loop2
[echo] outerLoop: outer_loop3
[echo] middleLoop: middle_loop1
[echo] innerLoop: inner_loop1
[echo] innerLoop: inner_loop2
[echo] middleLoop: middle_loop2
[echo] innerLoop: inner_loop1
[echo] innerLoop: inner_loop2
[echo] middleLoop: middle_loop3
[echo] innerLoop: inner_loop1
[echo] innerLoop: inner_loop2 ### this step should be skipped
[echo] outerLoop: outer_loop4
[echo] middleLoop: middle_loop1
[echo] innerLoop: inner_loop1
[echo] innerLoop: inner_loop2
[echo] middleLoop: middle_loop2
[echo] innerLoop: inner_loop1
[echo] innerLoop: inner_loop2
[echo] middleLoop: middle_loop3
[echo] innerLoop: inner_loop1
[echo] innerLoop: inner_loop2