Microsoft MakeCode

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