Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

block function return value
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

block function return value

by adavid7 on Sat Nov 14, 2020 8:43 pm

It is nice that the FUNCTION block in MakeCode allows you to create your own functions and pass input parameters to the function.

But I don't see a way to specify a return value for a function that the calling block can use. It seems there should be a RETURN block that you could insert into a function you define, and optionally return a value!

Am I missing something ?

adavid7
 
Posts: 68
Joined: Fri Jul 04, 2014 7:32 pm

Re: block function return value

by nickine9 on Mon Nov 16, 2020 4:40 am

there is a beta version of the makdecode editor: https://makecode.microbit.org/beta#editor

and if you look in the functions section you will see two blocks

1) return

2) call function (this has rounded edges)

the help section has an example in the return section.

i've only tried a quick test with numbers so i don't know if you can return other datatype.

hope that helps

nick

nickine9
 
Posts: 147
Joined: Fri Jan 06, 2017 4:14 am

Re: block function return value

by adavid7 on Mon Nov 16, 2020 10:03 am

I should have mentioned that I am using the CPX, not micro:bit.

In makecode.adafruit.com, there is no such return block. (Nor can you create a boolean argument for the function, either.)

Does anyone know if there are updates in the works for the CPX version of makecode?

Thanks.

adavid7
 
Posts: 68
Joined: Fri Jul 04, 2014 7:32 pm

Re: block function return value

by nickine9 on Mon Nov 16, 2020 11:11 am

there is a bata version https://makecode.adafruit.com/beta/#editor

i haven't tried it but it does have a return block and possibly accepts boolean arguments but it doesn't have an extra round "call function`' block.

as its a beta im sure adfruit would welcome feedback.

nick

nickine9
 
Posts: 147
Joined: Fri Jan 06, 2017 4:14 am

Re: block function return value

by adavid7 on Mon Nov 16, 2020 1:25 pm

Thanks, Nick!

That looks good. Where is a good place to offer feedback on the beta release?

.Andy

adavid7
 
Posts: 68
Joined: Fri Jul 04, 2014 7:32 pm

Re: block function return value

by kevinjwalters on Mon Nov 16, 2020 2:05 pm

Their development team are active on this forum https://forum.makecode.com/

kevinjwalters
 
Posts: 960
Joined: Sun Oct 01, 2017 3:15 pm

Re: block function return value

by adavid7 on Thu Nov 19, 2020 8:43 pm

Nick, is there also documentation on other changes that are in the beta version?

adavid7
 
Posts: 68
Joined: Fri Jul 04, 2014 7:32 pm

Re: block function return value

by nickine9 on Fri Nov 20, 2020 5:10 am

im afraid i don't know i stumbled across the beta version when i was doing things with a microbit and crickit.

nick

nickine9
 
Posts: 147
Joined: Fri Jan 06, 2017 4:14 am

Please be positive and constructive with your questions and comments.