VEX - For loop with given range [SOLVED]

   7292   3   2
User Avatar
Member
130 posts
Joined: June 2016
Offline
Hi Guys,
Can someone please let me know how to loop with range in VEX, similar to the below python code.

for i in range(5, 8):
    print(i)

#Result is
# 5 
# 6 
# 7 

Thank you
Edited by Mohanpugaz - April 25, 2019 08:27:38
Mohan Pugaz
movfx
https://www.instagram.com/movfx/ [www.instagram.com]
https://www.youtube.com/channel/@_movfx
User Avatar
Member
1736 posts
Joined: May 2006
Offline
There's no built in range function in vex AFAIK, here's a litte hacky method to approximate it:

int foo[];
int start = 5;
int end = 8;
resize(foo,end-start);
foreach(int i; int e; foo) {
  foo[i]=start+i;
}

i[]@a = foo;
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
for(int i = 5; i < 8; i++){
    printf('%g', i);
}
>567
Edited by bonsak - April 25, 2019 06:53:40
http://www.racecar.no [www.racecar.no]
User Avatar
Member
130 posts
Joined: June 2016
Offline
Both of the methods are awesome!.Exactly does what I was looking for. Thanks a lot guys.
Mohan Pugaz
movfx
https://www.instagram.com/movfx/ [www.instagram.com]
https://www.youtube.com/channel/@_movfx
  • Quick Links