I’m making a P drive function, and I need a parameter for a number. For example, a line might be
error = turns-DriveTurns();
But with this I would get an error for no parameter within the parentheses. I have no real parameter in the DriveTurns function either, because I do not know what I would put as a parameter for a number, as simply “number” (with proper typing) doesn’t work.
I looked at how the built-in motor block functions work, with “rotation” as the number parameter. I tried that, and I was given the error that “‘rotation’ does not refer to a value”
What would I use instead.
DriveTurns() is calling the function DriveTurns, so you need to add all the arguments in the parenthesis that your function is expecting. In this instance, though, DriveTurns() should return a value because it’s being used in a math operation (to calculate error), so you should make sure that DriveTurns is an int function.
What would I put in the parentheses in the original function to say that the number I put in when calling it is how many times I want to repeat the action?
You’d need a for loop within your function to repeat it a certain number of times. You can use a paremeter to describe the number of times and pass it to the for loop which would use the variable to control the number of iterations.