Do- While loop asking for a semi colon?

   2283   2   0
User Avatar
Member
97 posts
Joined: May 2015
Offline
So i dont know why the vex wrangle is giving me an error when using the do-while loop to add a semicolon at the end of the condition of the while.

int currentpoint;
int lastpoint;
vector lastpos = point(0,“P”,13);

do
{
currentpoint = 16;
int mainp = neighbour(0,currentpoint,0);
vector pos = point(0,“P”,mainp);

}
while(currentpoint == lastpoint)
{

int area_p = nearpoints(0,pos,1.5);

foreach(int a; area_p)
{
vector array_pos = point(0,“P”,a);
if(pos == array_pos)
{
removeindex(area_p,0);
}
}

int array_len = len(area_p);

if(array_len < 1)
{
foreach(int p ; area_p)
{
setpointgroup(0,“intersection_p”,p,1);
}
}
else
{
currentpoint = pop(area_p,0);
//continue;
}
}
User Avatar
Member
8555 posts
Joined: July 2007
Online
how did you get that far in your code without noticing any of the errors?

do loop syntax is:
do {} while (condition)

yours looks like you are trying to have do and while loop combined:
do {} while () {}

so you either do:
do {} while (); {}
where your second {} is just statement block without any loop

or:
do {} while (); while () {}
where you first do a do loop with while condition and afterwards while loop, which s well clearly shows the difference about having a while at the end of the do loop and hence end with a semicolon or having a while at the beginning of a while loop and hence no semicolon

but that's by far not the only error in the code, unless some info was lost by pasting it here without a code formatting
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
97 posts
Joined: May 2015
Offline
tamte
how did you get that far in your code without noticing any of the errors?

do loop syntax is:
do {} while (condition)

yours looks like you are trying to have do and while loop combined:
do {} while () {}

so you either do:
do {} while (); {}
where your second {} is just statement block without any loop

or:
do {} while (); while () {}
where you first do a do loop with while condition and afterwards while loop, which s well clearly shows the difference about having a while at the end of the do loop and hence end with a semicolon or having a while at the beginning of a while loop and hence no semicolon

but that's by far not the only error in the code, unless some info was lost by pasting it here without a code formatting

Oh ok went back to the Loops and flow control page and i see wat i was doing wrong.In my head i was thinking it did the do once and than moves on to the while loop.
  • Quick Links