Do While a variable has a value?

Hi All!!

I am working on a Do While loop and was wondering how to have it loop through until a specific variable is empty. For example, I have a String Array (VarB) and want to set VarA equal to each entry in the array (and do something based off that) until there are no more entries left in the array.

DO WHILE
VarA = VarB(n)

n = n+1
CONDITION
???

Cheers!
s3vn

2 Likes

@s3vn
If you’re looping through a collection of any sort (array, list, dictionary, etc.) then you should use a For Each activity since that will automatically stop once it finishes looping through the object.

4 Likes

yah it can be like this
Do while
{
varA = varB(i)
}
i < varB.Count//condition be like this

Cheers @s3vn

yah it can be like this
Do while
{
varA = varB(i);
i = i+1;
}
i < varB.Count //condition be like this

hope this would help you

but this can be more easier with for each loop activity

Cheers @s3vn

2 Likes

@DanielMitchell, wow…not sure why I didn’t think of that. I am going to give it a shot, thanks so much!!

2 Likes

Well of course with For Each activity
–we will be passing the variable of type array, list, dictionary, ienumerable or any collections type of variable
–and changing the type argument in the property panel with type of the elements in those collections, like here we have array of string varB then the type argument property be like string in the for each activity property panel
–then inside the loop we can assign with a assign activity like this
varA = item.ToString
where varA is a variable of type string and item is the variable from for each activity which holds each value in the array variable that we have passed to the for each loop activity

hope this would help you
Cheers @s3vn

1 Like

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