# Program run error while loop in for

**URL:** <https://forum.dynamobim.com/t/program-run-error-while-loop-in-for/6246>\
**Category:** DesignScript\
**Created:** [September 17, 2016, 5:10pm UTC](https://forum.dynamobim.com/t/program-run-error-while-loop-in-for/6246 "2016-09-17T17:10:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dangthanhnam01.kt199](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dangthanhnam01.kt199/32/83686_2.png) [@dangthanhnam01.kt199](https://forum.dynamobim.com/u/dangthanhnam01.kt199)\
**Post date:** [September 17, 2016, 5:10pm UTC](https://forum.dynamobim.com/t/program-run-error-while-loop-in-for/6246/1 "2016-09-17T17:10:00Z")

</div>

There was something unusual in my scenario when combined for and while loop?  
Thanks everyone.

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/b/bd724a8474019b4de426e5db885a48f7d74869f8.png)

---

<div class="post-metadata">

**Author:** ![Thomas\_Mahon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_mahon/32/64209_2.png) [@Thomas\_Mahon](https://forum.dynamobim.com/u/Thomas_Mahon)\
**Post date:** [September 17, 2016, 5:54pm UTC](https://forum.dynamobim.com/t/program-run-error-while-loop-in-for/6246/2 "2016-09-17T17:54:58Z")

</div>

get rid of`[continue]` it has no purpose nor grammar in DesignScript

---

<div class="post-metadata">

**Author:** ![dangthanhnam01.kt199](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dangthanhnam01.kt199/32/83686_2.png) [@dangthanhnam01.kt199](https://forum.dynamobim.com/u/dangthanhnam01.kt199)\
**Post date:** [September 18, 2016, 1:06pm UTC](https://forum.dynamobim.com/t/program-run-error-while-loop-in-for/6246/4 "2016-09-18T13:06:21Z")

</div>

I noticed that there was a problem in my script does not work as required

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/6/6eb2dc916710bf5a3cb46831ea7d204643cfb21d.png)  
It’s like the following example:  
 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/6/6231f19c8fd638fd353bebb2659ab7008ae22c08.png)  
file dynamo: [filterdyn.dyn](https://forum.dynamobim.com/uploads/short-url/3KWG6xWL0UnhFpMEiEFYs63IhrK.dyn) (6.5 KB)

---

<div class="post-metadata">

**Author:** ![Thomas\_Mahon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_mahon/32/64209_2.png) [@Thomas\_Mahon](https://forum.dynamobim.com/u/Thomas_Mahon)\
**Post date:** [September 18, 2016, 1:19pm UTC](https://forum.dynamobim.com/t/program-run-error-while-loop-in-for/6246/5 "2016-09-18T13:19:10Z")

</div>

@dangthanhnam01.kt199 in imperative code blocks your qualification wont replicate which is why you are only getting 3 items so you should add a nested loop and iterate through the second list:

```
list1:int[]..[];
list2:int[]..[];

locdt=[Imperative]
{
	a1={};
	for (i in GetKeys(list1) )
	{
		a1[i]={};
		for (j in GetKeys(list2) )
		{
			a1[i][j] = list1[i]==list2[j];
		}
	}
	return = a1;
}; 

```

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/5/5d9932221b0575723f856440d67773f96ed35963.png)

---

<div class="post-metadata">

**Author:** ![Thomas\_Mahon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_mahon/32/64209_2.png) [@Thomas\_Mahon](https://forum.dynamobim.com/u/Thomas_Mahon)\
**Post date:** [September 18, 2016, 1:28pm UTC](https://forum.dynamobim.com/t/program-run-error-while-loop-in-for/6246/6 "2016-09-18T13:28:51Z")

</div>

You could also use Associative DesignScript to do this if you want to avoid all the loops (performance-wise should be quicker):

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/b/b70bd78f9be3e4cb4d0f5aa92484f4e89ee5e47c.png)

---

<div class="post-metadata">

**Author:** ![dangthanhnam01.kt199](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dangthanhnam01.kt199/32/83686_2.png) [@dangthanhnam01.kt199](https://forum.dynamobim.com/u/dangthanhnam01.kt199)\
**Post date:** [September 18, 2016, 1:31pm UTC](https://forum.dynamobim.com/t/program-run-error-while-loop-in-for/6246/7 "2016-09-18T13:31:11Z")

</div>

Today I used all my time to find out the answer to this problem. Thank you for letting me know this. Thank you very much :cười:

---

<div class="post-metadata">

**Author:** ![dangthanhnam01.kt199](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dangthanhnam01.kt199/32/83686_2.png) [@dangthanhnam01.kt199](https://forum.dynamobim.com/u/dangthanhnam01.kt199)\
**Post date:** [September 18, 2016, 1:41pm UTC](https://forum.dynamobim.com/t/program-run-error-while-loop-in-for/6246/8 "2016-09-18T13:41:36Z")

</div>

That’s what I thought. Everything was nice. It works perfect. Thank you 😌

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/a/a42d9a90b6759b4cbcf89736352c1870374e377a.png)
