Vex Code IQ - Reusing a method (a set of blocks)

Say I have a method - Go Straight. The only change is the distance to travel - that will be a variable, say BotDistance. How do I call this method multiple times in the overall code without copying these blocks multiple times. I would simply like to change the value passed to BotDistance.

2 ways really. Either create a variable which stores the distance, then have your movement code in a broadcast and use the variable to control the motor movements.
Better still is probably to use the new My Blocks feature and create a function that has one or more number inputs that you can use to pass the necessary parameters.

2 Likes

VexCode IQ Blocks has a function feature / ‘my blocks’ …what version of VexCode IQ ?

My Blocks was added in version 1.0.7 which is the latest release I believe.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.