MyBlocks not working

Bug.iqblocks (28.0 KB)

The attached project fails to download with
windows build for platform vexiq

"CXX src/main.cpp"

src/main.cpp:58:25: error: use of undeclared identifier 'Drive_Forward_Distance_Velocity__Velocity'; did you mean 'Drive_Right_Distance_Velocity__Velocity'?

BackMotor.setVelocity(Drive_Forward_Distance_Velocity__Velocity, percent); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Drive_Right_Distance_Velocity__Velocity src/main.cpp:57:91: note: 'Drive_Right_Distance_Velocity__Velocity' declared here void Drive_Right_Distance_Velocity(double Drive_Right_Distance_Velocity__Distance, double Drive_Right_Distance_Velocity__Velocity) { ^

src/main.cpp:59:26: error: use of undeclared identifier 'Drive_Forward_Distance_Velocity__Velocity'; did you mean 'Drive_Right_Distance_Velocity__Velocity'?

FrontMotor.setVelocity(Drive_Forward_Distance_Velocity__Velocity, percent); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Drive_Right_Distance_Velocity__Velocity src/main.cpp:57:91: note: 'Drive_Right_Distance_Velocity__Velocity' declared here void Drive_Right_Distance_Velocity(double Drive_Right_Distance_Velocity__Distance, double Drive_Right_Distance_Velocity__Velocity) { ^

src/main.cpp:74:33: error: use of undeclared identifier 'Drive_Forward_Distance_Velocity__Velocity'; did you mean 'Drive_Left_Distance_Velocity__Velocity'?

BackMotor.setVelocity((-1.0 * Drive_Forward_Distance_Velocity__Velocity), percent); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Drive_Left_Distance_Velocity__Velocity src/main.cpp:73:89: note: 'Drive_Left_Distance_Velocity__Velocity' declared here void Drive_Left_Distance_Velocity(double Drive_Left_Distance_Velocity__Distance, double Drive_Left_Distance_Velocity__Velocity) { ^

src/main.cpp:75:34: error: use of undeclared identifier 'Drive_Forward_Distance_Velocity__Velocity'; did you mean 'Drive_Left_Distance_Velocity__Velocity'?

FrontMotor.setVelocity((-1.0 * Drive_Forward_Distance_Velocity__Velocity), percent); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Drive_Left_Distance_Velocity__Velocity src/main.cpp:73:89: note: 'Drive_Left_Distance_Velocity__Velocity' declared here void Drive_Left_Distance_Velocity(double Drive_Left_Distance_Velocity__Distance, double Drive_Left_Distance_Velocity__Velocity) { ^

4 errors generated.

make: *** [vex/mkrules.mk:13: build/src/main.o] Error 1

make process closed with exit code : 2

yes, looks like you found a bug. Here’s a fixed version.
BugFixed.iqblocks (28.0 KB)

5 Likes

How do we avoid reproducing his bug again? Will there be an update to Code Blocks?

I’m not directly working on blocks, however, from what I can see it happens because you probably created code under a myBlock and then copy & pasted it under another one that had parameters of the same name (ie. velocity and direction). Yes, the blocks team will need to take a look at this, hopefully there will be an update to address it.

5 Likes

Parameters are unique to each My Block in the current implementation, so you can’t use a same-named parameter in a different My Blocks as of today.

This is something we’ll look into improving in the future.

4 Likes

But this is okay as long as they come from the same myBlock definition, correct? You can have speed in different definitions, but if you copy code you just have to redo the variables from the current myBlock? This has worked for us.

Correct. You can use the same parameter name In multiple My Blocks - there’s some naming magic behind the scenes to avoid conflicts. Each parameter is local to a my block, which works like a function.

So for example a My Block with the structure “turn left (degrees)” would actually name the “degrees” parameter block in C++ as something like “turn_left_degrees”. Thus using this parameter block in another my block such as “turn right (degrees)” would cause a compiler error as shown by the OP.

2 Likes