Just kinda need a some help

do any of you guys know how to see if your code works before you apply it to the bot?

I mean if you don’t see anything wrong with the code and you have no errors, the best way to see if it works is just to try it. Applying and testing your code on your robot is the best way to find problems and improve it.

7 Likes

Welcome to the VEXForum @bread1

As Xenon so greatly pointed out, if there are no errors, then the best way is to test it.

You can also build the program without compiling it, and that will give a more detailed explanation of the errors in the Output tab.

Build button is #1, the Output tab is #2

image

However, that solution really only provides more information on any errors that might be present, not if the code works.

I also like to think through my code very thoroughly, reading through each line of code to see what it does. This is one of the ways I check my code, and it can be really helpful when reading through code you don’t understand as well. For instance:

int addingfunction (int numbertoadd){
  int numbertoreturn = numbertoadd + 1;
}

If I were to read through this, I would say:
“Ok, the int word says that we will be creating a function, and that function will return an int. The function is called addingfunction, and it accepts one integer as an argument. Both starting and ending parenthesis are there. The argument is named numbertoadd. The function has both a starting and ending curly brace. Inside the function, it creates a local integer named number to return, and sets it equal to the argument plus 1. The function then ends, without returning a number, which is a requirement for the int type of function.”

I would then edit the code

int addingfunction (int numbertoadd){
  int numbertoreturn = numbertoadd + 1;
  return(numbertoreturn);
}

That is a sort of testing and error finding. You could also follow along with mathematical calculations on a calculator.

Still, the best solution is testing, at least in VEX.

5 Likes