The case of the While loop that didn’t evaluate

In this case, an ICE While loop wasn’t working as expected.
The customer was using Max Repeat to do something like this, but in ICE:

x = 2
cond = x > 0

i = 0
while cond:
	print i
	i = i + 1
	if i > 10: break

Unfortunately, in ICE, the While loop was never executed.

It’s not a problem with the While loop, it’s a problem with the ICE tree evaluation (it’s a bit too lazy). I’ve seen things like this before, and I usually create a separate ICE tree to workaround it:

On the mailing list, Guillaume suggested a couple of other workarounds. First, use Delay Set Data.
The word “Delay” in the node name throws me off…I wouldn’t think to use it, but after reading up on it, I can see why you would think to use that node (it does evaluation).

If you set the condition boolean in the While loop, that works too:

4 thoughts on “The case of the While loop that didn’t evaluate

  1. Highlighting and explaining the “lazy evaluation” seems to be the only thing still missing explicitly from your “Top 10” list… (If all else fails, blame it on the “lazy evaluation”… :D)

  2. I’ve had a while loop that ran per point and wouldn’t execute its port, but only occasionally. The condition was per-object. As soon as I forced the condition to a per-point context, it did work fine.

    • Did I say while? 😀 It was a “repeat with counter” and it wasn’t even the condition but the num iterations. Num iterations was per object and once I forced it to a per-point context, it worked.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s