4

I have the retail EV3 kit and have created a function with in and out numeric parameters.

While using the [in] params seem quite straight forward, it seems that I can only set the [out] param once. Dragging a second wire from a constant or variable will not connect when I place them.

Can I only set an [out] param once?

Does setting the [out] param act like the "return" keyword?

I have had a look around, but there is very little help on the EV3 My Blocks at present.

Bad, but simple example:My Blocks return example

Please note that this is a simplification of the problem, and in this case I could set x to -1 or have another case in the sensor switch to set x to -1. I am trying to explorer the limitations of EV3 My Blocks out parameters.

1
  • Can you post a screenshot of the function?
    – dfrevert
    May 18, 2014 at 21:57

3 Answers 3

2

Can I only set an [out] param once?

Yes. You cannot tell it to be 2 different values at the same time. This applies to any block, not just the output block.

Does setting the [out] param act like the "return" keyword?

Not really. The return keyword in most (if not all) programming languages causes the function to exit, which is not the case here. It just allows you to assign the output value (or values - you can have more than one output parameter).

0

I think this is as close as you'll get (other than the constant being set to 99 instead of -1). You end up with 2 output parameters instead of one. If you really want only one output, you'll need some logic to determine which to output.

A similar MyBlock that returns two output parameters

0

I don't think I showed a great example. Using David Lechner's advice I changed the code to be more like the below:enter image description here

I use x to store my return value, and when loop 02 is finished, x is copied to the output param.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.