8
Views
8
Comments
Solved
For each loop being skipped
Question
Application Type
Reactive

My For Each loop is being skipped and I'm not sure why, as I have a list, a start index, and the number of iterations set to a non-zero number using an expression. Yet when I run my code, the For Each loop is skipped and the code goes straight to the End node. Does anyone know why this might be happening 

forLoopTest.png

Rank: #34631
Solution

Nevermind, I found the answer by using a If statement instead. Thanks for the help! 

forLoopTest.png

Rank: #86

Hello there Lynn,

Hope you're doing well.

Did you validate that your textList local variable has any elements?

If the list has no elements (empty), the Loop is skipped since there are no elements to iterate.


Looking to your image, the list seems to be empty :)


Kind regards,

Rui Barradas

Rank: #34631

oh, I don't have any elements in my list, as my list was meant to take a word or phrase, and add each character as an element for the list. So, a word like "heart" would have 4 elements: "h", "e", "a", "r", "t". Is there a way I can start with an empty list and then add elements to the list after I have the word/phrase?

Rank: #34631
Solution

Nevermind, I found the answer by using a If statement instead. Thanks for the help! 

forLoopTest.png

Champion
Rank: #269

Hi Lynn,


I notice that textList is not a parameter input, so if you didn't fill this variable with data, it'll considered empty, hence the for will skipped.

Rank: #34631

copying my other reply from above since it applies here to:

oh, I don't have any elements in my list, as my list was meant to take a word or phrase, and add each character as an element for the list. So, a word like "heart" would have 4 elements: "h", "e", "a", "r", "t". Is there a way I can start with an empty list and then add elements to the list after I have the word/phrase?


Champion
Rank: #269

Hi Lynn,

Yes, so the reason loop is skipped because you didn't initialize the textList or add data to it.

About your question to add data to the variable, you can use ListAppend from System action

Thanks

Rank: #34631


Thanks you, I was able to get it working by using an If statement instead. Thanks for the help!

forLoopTest.png

Champion
Rank: #269