# My example of imperative does not work, why?

**URL:** <https://forum.dynamobim.com/t/my-example-of-imperative-does-not-work-why/71552>\
**Category:** DesignScript\
**Created:** [December 20, 2021, 2:39pm UTC](https://forum.dynamobim.com/t/my-example-of-imperative-does-not-work-why/71552 "2021-12-20T14:39:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [December 20, 2021, 2:39pm UTC](https://forum.dynamobim.com/t/my-example-of-imperative-does-not-work-why/71552/1 "2021-12-20T14:39:58Z")

</div>

Hello dynos,

I try to understand imperativ and his practical use.  
Do you know something about it f.e.:

 ![2021-12-20_15h37_14](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/6/f6313401e362bc78a48852226754736cfb8d7d66.png)  
Is there a `Maths.Rand` comment? or do i use wrong syntex?

Do you have other exampels?

KR

Andreas

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [December 20, 2021, 2:57pm UTC](https://forum.dynamobim.com/t/my-example-of-imperative-does-not-work-why/71552/2 "2021-12-20T14:57:15Z")

</div>

This might help you out:  
https://www.youtube.com/embed/SndGdDpeY84?feature=oembed&wmode=opaque&list=PLdlF7MirPEC2yNFTGymESd3t7Xosfk9c2

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [December 20, 2021, 4:17pm UTC](https://forum.dynamobim.com/t/my-example-of-imperative-does-not-work-why/71552/3 "2021-12-20T16:17:53Z")

</div>

I have no idea… but if I write it as \>\>DSCore.Maths.Rand\<\< it goes grey

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [December 20, 2021, 4:23pm UTC](https://forum.dynamobim.com/t/my-example-of-imperative-does-not-work-why/71552/4 "2021-12-20T16:23:36Z")

</div>

![2021-12-20_17h22_58](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/7/874f949b1390ff9b49b819e1eec1fc572bfcefa9.png)  
 ![2021-12-20_17h25_02](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/d/1d7f8cba2bcf90487de31182d7ae3ebede26129c.png)

But it is still not working  
i try random list  
It could also be a tapstop problem, the output is 6 times cero so it adds nothing to the interation(i)

in Python i would use append! but in designScript i don`t know

KR

Andreas

---

<div class="post-metadata">

**Author:** ![EdsonMatt](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/edsonmatt/32/124725_2.png) [@EdsonMatt](https://forum.dynamobim.com/u/EdsonMatt)\
**Post date:** [December 20, 2021, 4:30pm UTC](https://forum.dynamobim.com/t/my-example-of-imperative-does-not-work-why/71552/5 "2021-12-20T16:30:01Z")

</div>

You’re writing “Maths”, try `DSCore.Math.Round(x)`.

Maths is from archilab.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/4/94853af25a56c603d678d321b0ef65116d295505.png)

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [December 20, 2021, 5:02pm UTC](https://forum.dynamobim.com/t/my-example-of-imperative-does-not-work-why/71552/6 "2021-12-20T17:02:46Z")

</div>

Hahaha!! I didn’t spot that!

Surprised I personally don’t do that more often tbh.

I’ve got used to typing, “color” instead of “colour”…

Shame we can’t have proper English in Python as well as the American 😆

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [December 21, 2021, 8:41am UTC](https://forum.dynamobim.com/t/my-example-of-imperative-does-not-work-why/71552/7 "2021-12-21T08:41:00Z")

</div>

![2021-12-21_09h38_30](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/8/587871252692514c058ad263be9914e17fa1011d.png)

i tried this, just for understanding:  
Why i need “x” ?  
f.e. when i say x = 1, every i+x is the same  
Why does x know it is a float?

KR

Andreas

---

<div class="post-metadata">

**Author:** ![EdsonMatt](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/edsonmatt/32/124725_2.png) [@EdsonMatt](https://forum.dynamobim.com/u/EdsonMatt)\
**Post date:** [December 21, 2021, 1:31pm UTC](https://forum.dynamobim.com/t/my-example-of-imperative-does-not-work-why/71552/8 "2021-12-21T13:31:42Z")

</div>

> [@Draxl\_Andreas](#):
>
> Why i need “x” ?

You don’t need “x”, I’ve just used x for example purpose and, of course, because the function `Round` requires an argument.

> [@Draxl\_Andreas](#):
>
> f.e. when i say x = 1, every i+x is the same

In your case, when you use x = 1 the for loop add each i to the value:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/8/c844aaa26e910850ce6978cc9068742aa745707c.png)

> [@Draxl\_Andreas](#):
>
> Why does x know it is a float?

This is interesting, although the function requires the input as `integer,` if you feed it with variables, it’ll output different numbers haha.

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