# Functions with a return value in Blocks

**URL:** <https://forum.makecode.com/t/functions-with-a-return-value-in-blocks/534>\
**Category:** PXT\
**Created:** [September 15, 2019, 8:30pm UTC](https://forum.makecode.com/t/functions-with-a-return-value-in-blocks/534 "2019-09-15T20:30:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [September 15, 2019, 8:30pm UTC](https://forum.makecode.com/t/functions-with-a-return-value-in-blocks/534/1 "2019-09-15T20:30:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [December 28, 2019, 2:09pm UTC](https://forum.makecode.com/t/functions-with-a-return-value-in-blocks/534/2 "2019-12-28T14:09:42Z")

</div>

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-code](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/db9c61fde42f06365109586852df3ae3546b76df.png)

![arcade-Hacky-Function-Returns-screenshot-simscreen](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/379ad8a591f523bb2eb464bcd9ad691acbcd0325.png)

---

<div class="post-metadata">

**Author:** ![jedgarpark](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jedgarpark/32/202_2.png) [@jedgarpark](https://forum.makecode.com/u/jedgarpark)\
**Post date:** [July 8, 2020, 8:43pm UTC](https://forum.makecode.com/t/functions-with-a-return-value-in-blocks/534/3 "2020-07-08T20:43:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [July 13, 2020, 5:31pm UTC](https://forum.makecode.com/t/functions-with-a-return-value-in-blocks/534/4 "2020-07-13T17:31:23Z")

</div>

![mchammer](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/5feae5cfe687f2a90ada8818a1b4e3785c5ceacd.gif) Great news! ![mchammer-left](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/f3a19860404bf2371b454d60efcf597d20215663.gif)

---

<div class="post-metadata">

**Author:** ![GameGod](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gamegod/32/2756_2.png) [@GameGod](https://forum.makecode.com/u/GameGod)\
**Post date:** [July 13, 2020, 5:50pm UTC](https://forum.makecode.com/t/functions-with-a-return-value-in-blocks/534/5 "2020-07-13T17:50:41Z")

</div>

[![](https://media.tenor.com/images/d3fb5a678eebb7a0f3bcbb8e9ac4b538/tenor.gif) ](https://media.tenor.com/images/d3fb5a678eebb7a0f3bcbb8e9ac4b538/tenor.gif)

---

<div class="post-metadata">

**Author:** ![stevensrmiller](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/stevensrmiller/32/5173_2.png) [@stevensrmiller](https://forum.makecode.com/u/stevensrmiller)\
**Post date:** [October 27, 2021, 3:11am UTC](https://forum.makecode.com/t/functions-with-a-return-value-in-blocks/534/6 "2021-10-27T03:11:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jedgarpark](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jedgarpark/32/202_2.png) [@jedgarpark](https://forum.makecode.com/u/jedgarpark)\
**Post date:** [October 27, 2021, 4:08pm UTC](https://forum.makecode.com/t/functions-with-a-return-value-in-blocks/534/7 "2021-10-27T16:08:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![stevensrmiller](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/stevensrmiller/32/5173_2.png) [@stevensrmiller](https://forum.makecode.com/u/stevensrmiller)\
**Post date:** [October 27, 2021, 6:54pm UTC](https://forum.makecode.com/t/functions-with-a-return-value-in-blocks/534/8 "2021-10-27T18:54:56Z")

</div>

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

Thanks!

---

<div class="post-metadata">

**Author:** ![jedgarpark](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jedgarpark/32/202_2.png) [@jedgarpark](https://forum.makecode.com/u/jedgarpark)\
**Post date:** [October 28, 2021, 5:14pm UTC](https://forum.makecode.com/t/functions-with-a-return-value-in-blocks/534/9 "2021-10-28T17:14:56Z")

</div>

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