Functions with a return value in Blocks

What’s the story with functions and return values? It looks like these cannot be done in pure Blocks? I know Scratch took this approach for some reason but I’d quite like a return value at the moment. I can hack it with a global value but it’s ugly and I might stomp on the value accidentally if I use the function from different places.

I flicked into JavaScript mode to add the return statement as an experiment. I thought that would turn into a single grey block but it’s actually annihilated my function definition and put the whole thing into a grey block that I now cannot call from Blocks.

This has the elegance of adding TCP/IP to Windows 3.11 but it’s viable for returning numbers in Arcade for the desperate Blocks programmer:

arcade-Hacky-Function-Returns-screenshot-simscreen

Have you seen that functions now have return blocks? Very cool!

1 Like

mchammer Great news! mchammer-left

Got a link for that? Would love to know how to do it.

No link, but you need to be in beta and then make a function. Once you have a function block you can pick a return block from the function category.

Ah, beta, you say? I’m using the Adafruit version, which doesn’t appear to have return blocks (alas).

Thanks!

That’s what I was using too — just add “/beta” to the end of the URL and you’ll be in the beta version