# DesignScript vc Formula (IF statement)

**URL:** <https://forum.dynamobim.com/t/designscript-vc-formula-if-statement/27917>\
**Category:** DesignScript\
**Created:** [November 1, 2018, 8:57am UTC](https://forum.dynamobim.com/t/designscript-vc-formula-if-statement/27917 "2018-11-01T08:57:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michal\_Dengusiak](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/michal_dengusiak/32/92831_2.png) [@Michal\_Dengusiak](https://forum.dynamobim.com/u/Michal_Dengusiak)\
**Post date:** [November 1, 2018, 8:57am UTC](https://forum.dynamobim.com/t/designscript-vc-formula-if-statement/27917/1 "2018-11-01T08:57:53Z")

</div>

After BiLT EUR 2018 thanks @solamour I am really keen on Design Script approach.  
I tested my current codes and found one example with issue.  
Any idea why my formula is not working any more? It used to work fine before. Now I am on Dynamo 1.3.3.411 and have to use alternative so for me will be great practise with Design Scripts.  
This is super simple but can I simplified my code. Do I alway need have: result and data?

```
x;
y;
z;
data = [Imperative]
{
	if(x == true)
		{
			result = y;
		}
	else
		{
			result = z;
		}
	return = result;
};

```

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/7/576e5f4179aebee549b41e0dc9de412fcf649dd2.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/7/67d076a254e52937ca2ea09b43065ef31a613f57.png)

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [November 1, 2018, 10:55am UTC](https://forum.dynamobim.com/t/designscript-vc-formula-if-statement/27917/2 "2018-11-01T10:55:14Z")

</div>

Hey,

I certainly get more true’s than i was expecting, it’s obviously matching the length of the longer input…

Hopefully @solamour can explain why…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/1/41c772beabc699137269a9c65409ea4a83127dd5.png)

I also find it interesting that the formula node doesn’t care whether True has a T or a t, and that it doesn’t care if it has a = or a ==.

Mark

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [November 1, 2018, 10:58am UTC](https://forum.dynamobim.com/t/designscript-vc-formula-if-statement/27917/3 "2018-11-01T10:58:38Z")

</div>

Incidently, if you aren’t aware, this is how Clockwork achieves the If with different list lengths…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/a/6a66a8e5371d11c0e6f51de7613b56ed3177860e.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:** [November 1, 2018, 11:13am UTC](https://forum.dynamobim.com/t/designscript-vc-formula-if-statement/27917/4 "2018-11-01T11:13:54Z")

</div>

Hi @Michal_Dengusiak DS ternary operators cant return singletons and lists. The deepest rank will fix the replication (basically it defaults to ‘longest lacing’ using Dynamo terminology) which is why you get different results then the if statement, which can handle outputting singletons and lists from its arguments. I believe this is a limitation in DS - I reported it ages ago on the GitHub but it looks like nothings changed…

---

<div class="post-metadata">

**Author:** ![Michal\_Dengusiak](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/michal_dengusiak/32/92831_2.png) [@Michal\_Dengusiak](https://forum.dynamobim.com/u/Michal_Dengusiak)\
**Post date:** [November 1, 2018, 3:03pm UTC](https://forum.dynamobim.com/t/designscript-vc-formula-if-statement/27917/5 "2018-11-01T15:03:28Z")

</div>

thanks @Thomas_Mahon for your great session at BiLT EUR 2018…😀  
great this is logged now  
this is interesting to see 486 Issues open under Dynamo GitHub today

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [November 1, 2018, 6:04pm UTC](https://forum.dynamobim.com/t/designscript-vc-formula-if-statement/27917/6 "2018-11-01T18:04:52Z")

</div>

For using **DesignScript** I typically create an **If** statement as follows:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/3/03a3048192160de805434d4d4786a1520eb51856.png)
