Create function with "return"

Hi.
I am a bit confused and I am wondering if anyone can explain to me why this is happening:

I want to create a function with a return:
Screenshot 2021-04-27 at 11.16.29

But I get confused.
When I create this function and then want to call it, it is now looking like this:

See the different from the function: “do something”?

And if I want to add the piece “return”, then the output is closing, so there is no way to add any output for the return…

Is this normal behaviour? How can I do something like this then: (which I want to) ?

Thanks!

1 Like

Hi there,

If a function returns a given value, then that function will appear as a value block so that the value it returns can be used in other blocks, like this:

Where are you finding this return block that does not allow you to specify the value to return?

I still see the usual return block that lets you attach a value:
Screen Shot 2021-04-27 at 11.48.12 AM

Which allows you to do something like this, or like the sample function you posted:

1 Like

Thanks for your reply.
Well, I do see these also, but as soon as I “add” the block to the project the “output” disappears.
Or if I have created a function with a return block from start, I won’t be able to just call it later, I need to add it as an “output”…
See what I mean?

If I use the simple “create function-block”, without any return - I can call this to any block later.

If I create a function WITH return, I can not call that in the same way as the other function, I need to “add” it as an output/value somewhere…

If I creat a simple function without return and then ADD a return block to that function, the “output-opening” is closing, so I can’t add anything there later on…

Please see video shot here:

I am sorry for my bad “code-languish”, I am not sure how to formulate my self.

Maybe this is a completely normal behaviour, it’s just that I don’t understand it… So I need to ask.

Thanks

Does it help to know that you can change a variable (any variable’s) value from within a standard function?

The function with return block is really only for times when you need to have the returned value immediately available as a block. Otherwise, you can just use the standard function block.

I’ve never used the standalone “return” block in a function. I’m honestly not sure what it does.

1 Like

Can you explain what you want the function to do?

For example, I might say “I want to calculate the square root of a number the user types in” or “I want to sort a list I have stored in a variable in reverse order.”

What is it you’re actually wanting to do with functions?

1 Like

Thanks!
Yea, I want to loop/repeat my call for my data list until there is something in the list, and if there never gets anything in that list (It’s empty) I want to “break” that loop after a wile by just RETURN to my empty list…

Thanks!

Hi there,

In this video, you drag out a function that does not return a value.
Can you drag out the second function block, that does contain a return block, and see if that works in your app? It’s called ‘do something and return’ in this video.

1 Like