# Design Script If Logic Failure

**URL:** <https://forum.dynamobim.com/t/design-script-if-logic-failure/59494>\
**Category:** DesignScript\
**Tags:** function, dynamo\
**Created:** [January 19, 2021, 9:16pm UTC](https://forum.dynamobim.com/t/design-script-if-logic-failure/59494 "2021-01-19T21:16:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![smichaudN26PG](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@smichaudN26PG](https://forum.dynamobim.com/u/smichaudN26PG)\
**Post date:** [January 19, 2021, 9:16pm UTC](https://forum.dynamobim.com/t/design-script-if-logic-failure/59494/1 "2021-01-19T21:16:55Z")

</div>

I am pulling my hair out in frustration. I’m trying to nest the logic of vector math in a design script function. I want the input HostTypeString to check if it is “Wall” if so do the vector math and return 1 angle double.  
some how it says my input of true does not equal true (or the string wall when I rearrange it to remove the == node block.) and returns more items and sub lists somehow. if I remove the [0] indexing in the function it returns a list of 2 nulls for some reason. Does any one have any ideas on why a function with an if logic returns more list items then items to check for the if statement for?

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

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [January 19, 2021, 9:26pm UTC](https://forum.dynamobim.com/t/design-script-if-logic-failure/59494/2 "2021-01-19T21:26:58Z")

</div>

`if(HostTypeString[0] == true)`  
Your input is a single value of `true` but your function is looking for a list with a 0 index value of `true`. That’s why it’s failing. This is the same reason your output is two sublists (not sure if that’s on purpose or not).

---

<div class="post-metadata">

**Author:** ![smichaudN26PG](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@smichaudN26PG](https://forum.dynamobim.com/u/smichaudN26PG)\
**Post date:** [January 19, 2021, 9:29pm UTC](https://forum.dynamobim.com/t/design-script-if-logic-failure/59494/3 "2021-01-19T21:29:49Z")

</div>

Thanks for the guess @Nick_Boyts but with out the index call on the HostTypeString i get nulls instead

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/6/86d9ea0bd9626b4310e083a58aaf05901e919d3b.png)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [January 19, 2021, 9:32pm UTC](https://forum.dynamobim.com/t/design-script-if-logic-failure/59494/4 "2021-01-19T21:32:42Z")

</div>

That’s because the body of your function isn’t working correctly. I’m guessing you have to define your input as a list (unfortunately I don’t know how to do that for DS off the top of my head.) Right now you’re feeding a list (two points) as a singular input, but there’s nothing telling your function to use the entire list as the input, so it’s trying to loop through two values.

---

<div class="post-metadata">

**Author:** ![smichaudN26PG](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@smichaudN26PG](https://forum.dynamobim.com/u/smichaudN26PG)\
**Post date:** [January 19, 2021, 9:35pm UTC](https://forum.dynamobim.com/t/design-script-if-logic-failure/59494/5 "2021-01-19T21:35:49Z")

</div>

I think i get what you saying. Like when you lace with Auto and it sees 2 items in a list so it might jump to longest due to the Auto setting vs shortest

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [January 19, 2021, 9:37pm UTC](https://forum.dynamobim.com/t/design-script-if-logic-failure/59494/6 "2021-01-19T21:37:08Z")

</div>

Correct. Easiest thing to do in this scenario would be to use three separate inputs. That way you can feed it the boolean, start point, and end point directly.

---

<div class="post-metadata">

**Author:** ![Michael\_Kirschner2](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/michael_kirschner2/32/75576_2.png) [@Michael\_Kirschner2](https://forum.dynamobim.com/u/Michael_Kirschner2)\
**Post date:** [January 20, 2021, 2:00am UTC](https://forum.dynamobim.com/t/design-script-if-logic-failure/59494/7 "2021-01-20T02:00:03Z")

</div>

the way to mark an input as a list is like this:

`def myFunc(aSingleItem:var, alist:var[], aCrazyNestedList: var[]..[] () {}`

the `var[]..[]` is an arbitrary rank array and it means the function will not replicate over that input, ever.
