Hi
Can I write an if statement in a channel field so then I can set the value of that channel if the condition is true?
Thanks
Expressions in channel field
2031 7 0- SteN
- Member
- 55 posts
- Joined: March 2015
- Offline
- BabaJ
- Member
- 2024 posts
- Joined: Sept. 2015
- Offline
Yes you can.
I don't know how to do it in Hscript
But if you set the expression language icon ( upper right hand corner of Parameter Window Pane in which your “channel field” resides ) to Python the code below will work.
In this case I have a box and the tx - “channel field” has the following code put in it.
the my_var_B variable is linked to the boxes ty position parameter.
So tx of the box will always be at position 2 unless ty is 2 which at the point tx becomes 4.
I don't know how to do it in Hscript
But if you set the expression language icon ( upper right hand corner of Parameter Window Pane in which your “channel field” resides ) to Python the code below will work.
In this case I have a box and the tx - “channel field” has the following code put in it.
the my_var_B variable is linked to the boxes ty position parameter.
So tx of the box will always be at position 2 unless ty is 2 which at the point tx becomes 4.
result = 0 my_var_A = 2 my_var_B = ch("ty") if(my_var_A == my_var_B): result = 4 else: result = 2 return result
Edited by BabaJ - July 30, 2016 15:29:17
- Nima
- Member
- 471 posts
- Joined: Nov. 2013
- Offline
- SteN
- Member
- 55 posts
- Joined: March 2015
- Offline
Thanks for the fast reply.
What about VEX?
I wrote this in the “n°of copies” channel in a copy sop but gives me error.
EDIT:
Ok I tried the Hscript one and it works, but why cant I just write in vex in channels but just in wrangles?
What about VEX?
I wrote this in the “n°of copies” channel in a copy sop but gives me error.
int x = ch("../Height/Bricks_in_height"); int result; if (x%2 = 0) { result = x/2; } return result;
EDIT:
Ok I tried the Hscript one and it works, but why cant I just write in vex in channels but just in wrangles?
Edited by SteN - July 30, 2016 18:21:55
- Nima
- Member
- 471 posts
- Joined: Nov. 2013
- Offline
- SteN
- Member
- 55 posts
- Joined: March 2015
- Offline
- Nima
- Member
- 471 posts
- Joined: Nov. 2013
- Offline
- SteN
- Member
- 55 posts
- Joined: March 2015
- Offline
-
- Quick Links