Code trouble

#1

I am also having trouble and im wondering if you can help me.
Here is my code:

repeatUntil(  getBumperValue == 0 ){
  if(getBumperValue(Bumper) == 0) {
   motor[port8] = 127;
   motor[port9] = -127;
  }else{
   motor[port8] = -127;
   motor[port9] = 127;
  }
}
0 Likes

Executable statements not valid in 'main'
#2

@Bacov You should start a thread about your issue and not revive a 6 year old thread. Also, when you next go to post your code, highlight your code and click on the </> button. It will preserve the code formatting and keep it readable, like this:

int main(void) {
    //readable, formatting preserved
}

@DRow

0 Likes

#3

Without what knowing what you want your code to do or what specifically is wrong (i.e., how the current behavior of your code differs from the expected or desired behavior, any compiler errors/warnings you’re getting, etc.) it’s hard to debug your program.

However, here are some thoughts based on the code snippet you posted:

  • First, in your repeatUntil loop, getBumperValue should be a function call, not a variable. That line should be repeatUntil( getBumperValue(bumperName) == 0 ){, where bumperName is the name of the relevant bumper.
  • Secondly, I’m assuming the bumper switch used in the repeatUntil statement is different to that referenced in the if statement. If the same bumper is used in both lines, you know that when the content of the repeatUntil statement will only run when the button is pressed, so the if statement is unnecessary in that case.
0 Likes