# Unofficial Reply: How does this code work?

``````
if(vexRT[Btn7D] == 1)
{
motor[left_bttm] = 45;
motor[left_mid] = 45;
motor[left_top] = 45;
motor[right_bttm] = 45;
motor[right_mid] = 45;
motor[right_top] = 45;
wait1Msec(100);
}
else
{
motor[left_bttm] = 0;
motor[left_mid] = 0;
motor[left_top] = 0;
motor[right_bttm] = 0;
motor[right_mid] = 0;
motor[right_top] = 0;
}

if(vexRT[Btn7L] == 1)
{
motor[left_bttm] = 65;
motor[left_mid] = 65;
motor[left_top] = 65;
motor[right_bttm] = 65;
motor[right_mid] = 65;
motor[right_top] = 65;
wait1Msec(100);
}
else
{
motor[left_bttm] = 0;
motor[left_mid] = 0;
motor[left_top] = 0;
motor[right_bttm] = 0;
motor[right_mid] = 0;
motor[right_top] = 0;
}

if(vexRT[Btn7U] == 1)
{
motor[left_bttm] = 90;
motor[left_mid] = 90;
motor[left_top] = 90;
motor[right_bttm] = 90;
motor[right_mid] = 90;
motor[right_top] = 90;
wait1Msec(100);
}
else
{
motor[left_bttm] = 0;
motor[left_mid] = 0;
motor[left_top] = 0;
motor[right_bttm] = 0;
motor[right_mid] = 0;
motor[right_top] = 0;
}

``````

I’m assuming the above code is in a while loop. Is this correct?
I honestly am not sure why this code works, and why the motors do not experience crazy amounts of jitter (I’m assuming they don’t, or your programming team probably would have rewritten it already). If you want to correct this inexplicable functionality, you can make it one series of if-else if-else statements. That would look like this:

``````
if(vexRT[Btn7D] == 1)
{
motor[left_bttm] = 45;
motor[left_mid] = 45;
motor[left_top] = 45;
motor[right_bttm] = 45;
motor[right_mid] = 45;
motor[right_top] = 45;
wait1Msec(100);
}
else if(vexRT[Btn7L] == 1)
{
motor[left_bttm] = 65;
motor[left_mid] = 65;
motor[left_top] = 65;
motor[right_bttm] = 65;
motor[right_mid] = 65;
motor[right_top] = 65;
wait1Msec(100);
}

else if(vexRT[Btn7U] == 1)
{
motor[left_bttm] = 90;
motor[left_mid] = 90;
motor[left_top] = 90;
motor[right_bttm] = 90;
motor[right_mid] = 90;
motor[right_top] = 90;
wait1Msec(100);
}
else
{
motor[left_bttm] = 0;
motor[left_mid] = 0;
motor[left_top] = 0;
motor[right_bttm] = 0;
motor[right_mid] = 0;
motor[right_top] = 0;
}

``````

I’m not sure why your other programmer wrote the code using several if-else statements, rather than making else if statements.
I hope this helps, and good luck!