Discuss Scratch
- Me_Tis
-
100+ posts
Return Block
It seems that this thread has reached a conclusion. TM_ has created a project to explain it. http://scratch.mit.edu.ezproxyberklee.flo.org/projects/11829884/
My original post:
My original post:
For some reason, this wouldn't let me post images, even if I used imageshack.com. Here is a link to this same thing but with images:
https://dl.dropboxusercontent.com/u/17754076/Scratch/Return%20block.html
Return Block
My idea is that instead of there being a return block implemented so users could make the equivalent of an “int” or “String” function rather than the usual “void”, but instead that the “make a block” tab also had a “make a block (with return)”.
Image: https://dl.dropboxusercontent.com/u/17754076/Scratch/Make%20a%20block.png
The user would then have a the usual “make a block” input interface.
When defining the block, it would look something like this:
Image: https://dl.dropboxusercontent.com/u/17754076/Scratch/Make%20a%20block%202.png
Finally, the last step would be using the block:
Image: https://dl.dropboxusercontent.com/u/17754076/Scratch/Make%20a%20block%203.png
Image: https://dl.dropboxusercontent.com/u/17754076/Scratch/Make%20a%20block%204.png
Last edited by Me_Tis (Aug. 15, 2013 15:06:21)
- turkey3
-
1000+ posts
Return Block
You already can. Right-click on a custom block, click “edit”, and there are string, number, and boolean inputs. For some reason, this wouldn't let me post images, even if I used imageshack.com. Here is a link to this same thing but with images:
https://dl.dropboxusercontent.com/u/17754076/Scratch/Return%20block.html
Return Block
My idea is that instead of there being a return block implemented so users could make the equivalent of an “int” or “String” function rather than the usual “void”, but instead that the “make a block” tab also had a “make a block (with return)”.
Image: https://dl.dropboxusercontent.com/u/17754076/Scratch/Make%20a%20block.png
The user would then have a the usual “make a block” input interface.
When defining the block, it would look something like this:
Image: https://dl.dropboxusercontent.com/u/17754076/Scratch/Make%20a%20block%202.png
Finally, the last step would be using the block:
Image: https://dl.dropboxusercontent.com/u/17754076/Scratch/Make%20a%20block%203.png
Image: https://dl.dropboxusercontent.com/u/17754076/Scratch/Make%20a%20block%204.png
- Me_Tis
-
100+ posts
Return Block
I don't think you understand me. I am saying it would be nice if you could make a block and the block could return a number so you could put it in another block like this:
https://dl.dropboxusercontent.com/u/17754076/Scratch/Make%20a%20block%204.png
So you can make your own block that returns a value.
https://dl.dropboxusercontent.com/u/17754076/Scratch/Make%20a%20block%204.png
So you can make your own block that returns a value.
Last edited by Me_Tis (Aug. 13, 2013 14:19:39)
- turkey3
-
1000+ posts
Return Block
Oh! Good idea +1 I don't think you understand me. I am saying it would be nice if you could make a block and the block could return a number so you could put it in another block like this:
https://dl.dropboxusercontent.com/u/17754076/Scratch/Make%20a%20block%204.png
- TM_
-
1000+ posts
Return Block
I wanted this all the time, but i never had the idea how this could look. Now i saw your design and it looks great! The design with the c-block is simple and also genius. Also we never will need a return value variable when this block exists.
SUPPORT!
SUPPORT!
- drmcw
-
1000+ posts
Return Block
+1 for returning data, however your idea may need some work. You show the define block returning a value but there is still an attachment point so blocks could be added after the return which doesn't make sense. Although having a single return point is workable it's usually nicer to be able to return from within the function too e.g.
if x=0 then
return -1
return 1/x
if x=0 then
return -1
return 1/x
- scimonster
-
1000+ posts
Return Block
I think Snap!'s way is better.I think custom report blocks are planned for 2.1.
Until then, you can always use Snap!.
I know, just I like scratch and as far as I know they were planning to add a return block like Snap! does and I think my way is better.

But it's true that your way is a bit more intuitive.
- Me_Tis
-
100+ posts
Return Block
The whole point of scratch is intuitonI think Snap!'s way is better.I think custom report blocks are planned for 2.1.
Until then, you can always use Snap!.
I know, just I like scratch and as far as I know they were planning to add a return block like Snap! does and I think my way is better.Why? Your way, there's only one possible return value. With a return () block, you can make a block like (what type is ) and have it report number, string, boolean, etc. Or you could have an error message…
But it's true that your way is a bit more intuitive.

- Me_Tis
-
100+ posts
Return Block
I see what you mean but I think that this is the easiest way for new programmers to learn about functions returning anything. The attachment point was a mistake. +1 for returning data, however your idea may need some work. You show the define block returning a value but there is still an attachment point so blocks could be added after the return which doesn't make sense. Although having a single return point is workable it's usually nicer to be able to return from within the function too e.g.
if x=0 then
return -1
return 1/x
- TM_
-
1000+ posts
Return Block
I see what you mean but I think that this is the easiest way for new programmers to learn about functions returning anything. The attachment point was a mistake. +1 for returning data, however your idea may need some work. You show the define block returning a value but there is still an attachment point so blocks could be added after the return which doesn't make sense. Although having a single return point is workable it's usually nicer to be able to return from within the function too e.g.
if x=0 then
return -1
return 1/x
i thinkthat , too. With a return() block we would have more possibilities, but also syntax-error would appear and that is one thing that scratch never had.
Another way would to click on options and click add new return with boolean. So after the define block comes a c-block, like in your picture and on the bottom is instead of the numberinput a “if <boolean input> return (number or boolean input)”. If you want to add a new case for returning it looks like this:
“if <boolean input> return (number or boolean input)”
“else if <boolean input> return (number or boolean input)”
…
and at the end is always if you work with more than on cases a “default return ()”
What do you think? And can you make also a picture for this? Btw which programm do you use to make the blocks in a so good quality? It looks like real blocks.
I write down how it looks when i put my ideas together:
Define: Custom Block
c-block
if <boolean> return (number)
else if <boolean> return (number)
else return (number)
Also each number input should be replaceable with string or boolean, but the whole block can return only one value-type
- Me_Tis
-
100+ posts
Return Block
Sorry, TM_ I don't understand your suggestion.
I use Paint.NET. (The Hue/saturation was important for changing the color of the blocks so I could use a repeat(10) loop and change the color to the same as a custom block).
If you want more info on how I did the blocks I guess I could make a tutorial.
Maybe a string output would be better than a number output as technically you can store any data type in a string.
I use Paint.NET. (The Hue/saturation was important for changing the color of the blocks so I could use a repeat(10) loop and change the color to the same as a custom block).
If you want more info on how I did the blocks I guess I could make a tutorial.
Maybe a string output would be better than a number output as technically you can store any data type in a string.
- TM_
-
1000+ posts
Return Block
Sorry, TM_ I don't understand your suggestion.
I use Paint.NET. (The Hue/saturation was important for changing the color of the blocks so I could use a repeat(10) loop and change the color to the same as a custom block).
If you want more info on how I did the blocks I guess I could make a tutorial.
Maybe a string output would be better than a number output as technically you can store any data type in a string.
i will do a example project
- TM_
-
1000+ posts
Return Block
Sorry, TM_ I don't understand your suggestion.
I use Paint.NET. (The Hue/saturation was important for changing the color of the blocks so I could use a repeat(10) loop and change the color to the same as a custom block).
If you want more info on how I did the blocks I guess I could make a tutorial.
Maybe a string output would be better than a number output as technically you can store any data type in a string.
Check out this project: http://scratch.mit.edu.ezproxyberklee.flo.org/projects/11829884/
It shows my idea and how to build a block like this
- Scratch12300
-
500+ posts
Return Block
That helped illustrate the idea. Support.Sorry, TM_ I don't understand your suggestion.
I use Paint.NET. (The Hue/saturation was important for changing the color of the blocks so I could use a repeat(10) loop and change the color to the same as a custom block).
If you want more info on how I did the blocks I guess I could make a tutorial.
Maybe a string output would be better than a number output as technically you can store any data type in a string.
Check out this project: http://scratch.mit.edu.ezproxyberklee.flo.org/projects/11829884/
It shows my idea and how to build a block like this
- Me_Tis
-
100+ posts
Return Block
Sorry, TM_ I don't understand your suggestion.
I use Paint.NET. (The Hue/saturation was important for changing the color of the blocks so I could use a repeat(10) loop and change the color to the same as a custom block).
If you want more info on how I did the blocks I guess I could make a tutorial.
Maybe a string output would be better than a number output as technically you can store any data type in a string.
Check out this project: http://scratch.mit.edu.ezproxyberklee.flo.org/projects/11829884/
It shows my idea and how to build a block like this
Very good!!

I completely agree with your idea (and like the return boolean, number or string selection idea) other than I think it would be a little awkward to use your suggested if/elses at the bottom as you may want to use loops with if statements and all sorts of things that your suggestion wouldn't allow.
Please wait a minute while I draw my idea.
Last edited by Me_Tis (Aug. 13, 2013 21:12:17)
- Me_Tis
-
100+ posts
Return Block
This it my reply to TM_'s idea: going back to something similar to the return block (as nothing quite matches it's flexibility).
https://dl.dropboxusercontent.com/u/17754076/Scratch/Make%20a%20block%205.png
This is an example of how I could use my idea. It makes a more advanced version of the (letter ( ) of ) block: a (letter ( ) to ( ) of ) block.
https://dl.dropboxusercontent.com/u/17754076/Scratch/Make%20a%20block%205.png
This is an example of how I could use my idea. It makes a more advanced version of the (letter ( ) of ) block: a (letter ( ) to ( ) of ) block.
Last edited by Me_Tis (Aug. 13, 2013 21:59:36)
- Me_Tis
-
100+ posts
Return Block
It would make sense if the function returned the value in the first return block it finds then stops executing code. This would stop there being an error from multiple return blocks.
- TM_
-
1000+ posts
Return Block
It would make sense if the function returned the value in the first return block it finds then stops executing code. This would stop there being an error from multiple return blocks.
In other program languages it also stops after a return, but i gives you a snytax-error message when you have blocks behind a return. To your first post: I like thing with the + and i also got a new idea how to solve the problem with loops before a return and the return block always at the end. I will reedit my project and post it here again when it 's ready