Discuss Scratch

theonlygusti
Scratcher
1000+ posts

Return Block

This is already a planned, and pretty much implemented, feature of Scratch.
Zro716
Scratcher
1000+ posts

Return Block

yES!! YESS!!! ALL MY SUPPORT!!!!!!!exclamation!!!!one!

and I know exactly how this should work. seeing how blocks should be self-explanatory, I'll make sure to show an example that is easy to understand how everything will work. hopefully the ST will revisit this topic and see this post (). so off to the races…

let's start with creating a normal custom block:
New Block
base (2) to the power of (5) ::custom
▼Options
Add number input:
Add string input:
Add boolean input:
Add label text:

☑Run without screen refresh
Return a value
below the checkbox for screen refresh is the checkbox for returning a value. when checked…
New Block
(base (2) to the power of (5) ::custom)
▼Options
Add number input:
Add string input:
Add boolean input:
Add label text:

☑ Run without screen refresh
☑ Return a value
…the custom block becomes a custom reporter. and the definition block for it looks like this now:
(base (base ::custom) to the power of (power ::custom) ::custom) {return [] ::custom cap} ::custom hat
//it's supposed to be a definition block but "define" would make it parse wrong
not only does the appearance of the custom block nested in the procedure hat block look like a round operator, it also comes with a reporter cap block that you can drag into the script anywhere like a normal argument. if no return block is in the script the custom operator returns nothing.

so now to finish the script:
when gf clicked
ask [base] and wait
set [Base v] to (answer)
ask [exponent] and wait
set [Exponent v] to (answer)
set [Result v] to (base (Base) to the power of (Exponent) ::custom)
say (join [The result is ](Result))

(base (base ::custom) to the power of (power ::custom) ::custom) {return [] ::custom cap} ::custom hat
return ([10^ v] of (([log v] of (base ::custom)) * (power ::custom))) ::custom cap
I don't think this poses any ambiguities since the blocks explain themselves pretty well!
stickfiregames
Scratcher
1000+ posts

Return Block

Zro716 wrote:

I don't think this poses any ambiguities since the blocks explain themselves pretty well!
What if there is no return at the end?

Maybe it should be a combined hat / c block:
dеfine ((base ::custom-arg) ^ (power :: custom-arg) :: custom) :: custom hat
:: custom cstart
{return [] :: custom cap} :: custom cend
That would force it to reach a return.

Last edited by stickfiregames (Oct. 9, 2014 16:37:04)

theonlygusti
Scratcher
1000+ posts

Return Block

stickfiregames wrote:

Zro716 wrote:

I don't think this poses any ambiguities since the blocks explain themselves pretty well!
What if there is no return at the end?

Maybe it should be a c block:
dеfine (() ^ () :: custom) :: custom hat
:: custom cstart
{return [] :: custom cap} :: custom cend
That would force it to reach a return.
could have done:

deƒine (() ^ () :: custom) :: custom hat
:: custom cstart
return [] :: cend

Last edited by theonlygusti (Oct. 8, 2014 15:52:30)

TimothyLawyer
Scratcher
1000+ posts

Return Block

A problem with just being able to check and un-check a box to switch between stack and operator style blocks is:
  • What if the Scratcher already has the other kind of block in their project?

  • What happens to those blocks?

It could be confusing.

Maybe the checkbox would not work unless the block is not yet used in the project, or until all instances of the block were deleted from the project?

Or no checkbox at all. Just when a
return [] :: custom cap
is added to
define 
stack, if the custom block is already being used in the project, a dialog box comes up to let you know you need to delete all instances of the stack-style block before the 'return' block can be added the custom block outline changes from stack to operator (or vice versa).
stickfire-helper
Scratcher
24 posts

Return Block

theonlygusti wrote:

stickfiregames wrote:

Zro716 wrote:

I don't think this poses any ambiguities since the blocks explain themselves pretty well!
What if there is no return at the end?

Maybe it should be a c block:
dеfine (() ^ () :: custom) :: custom hat
:: custom cstart
{return [] :: custom cap} :: custom cend
That would force it to reach a return.
could have done:

deƒine (() ^ () :: custom) :: custom hat
:: custom cstart
return [] :: cend
But that doesn't look the same.
stickfiregames
Scratcher
1000+ posts

Return Block

theonlygusti wrote:

could have done:
deƒine (() ^ () :: custom) :: custom hat
:: custom cstart
return [] :: cend
That doesn't look the same though.
Zro716
Scratcher
1000+ posts

Return Block


stickfiregames wrote:

Zro716 wrote:

I don't think this poses any ambiguities since the blocks explain themselves pretty well!
What if there is no return at the end?
read the rest of the post. I already said if there wasn't a return block it would return nothing.
angrybird232
Scratcher
100+ posts

Return Block

scimonster wrote:

Me_Tis wrote:

scimonster wrote:

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.
I think Snap!'s 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.
Snap is a big lie about adding inputs and outputs to your blocks. Use BLOCKLY!!!!!!!!! Only blockly is possible to do EVERYTHING! I tried scratch,snap,and blockly and blockly only worked!

Last edited by angrybird232 (Dec. 13, 2014 04:01:22)

angrybird232
Scratcher
100+ posts

Return Block

stickfire-helper wrote:

theonlygusti wrote:

stickfiregames wrote:

Zro716 wrote:

I don't think this poses any ambiguities since the blocks explain themselves pretty well!
What if there is no return at the end?

Maybe it should be a c block:
dеfine (() ^ () :: custom) :: custom hat
:: custom cstart
{return [] :: custom cap} :: custom cend
That would force it to reach a return.
could have done:

deƒine (() ^ () :: custom) :: custom hat
:: custom cstart
return [] :: cend
But that doesn't look the same.
Only possible on blockly.
Zro716
Scratcher
1000+ posts

Return Block

angrybird232 wrote:

scimonster wrote:

Me_Tis wrote:

scimonster wrote:

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.
I think Snap!'s 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.
Snap is a big lie about adding inputs and outputs to your blocks. Use BLOCKLY!!!!!!!!! Only blockly is possible to do EVERYTHING! I tried scratch,snap,and blockly and blockly only worked!
I don't think you've used snap to its full potential.
angrybird232
Scratcher
100+ posts

Return Block

define return [string 1][scratchblocks]
deleted return
Scratcher1002
Scratcher
1000+ posts

Return Block

Wait, shouldn't this be another block?
receive from [ v] and put in variable [ v] :: custom
+1

Last edited by Scratcher1002 (Dec. 16, 2014 01:36:01)

Cyoce
Scratcher
500+ posts

Return Block

It should say “make a reporter”

Me_Tis wrote:


https://dl.dropboxusercontent.com/u/17754076/Scratch/Make%20a%20block%205.png
Lol you spelled “mistakes” as “misteakes”. Mistake on a mistake.

Also, I don’t understand why people put a return in the end of the c-block. Additionally, “return ( )” should be found under “more blocks”, not be clicking on a (+) sign that has not been programmed into Scratch.

Last edited by Cyoce (Dec. 16, 2014 02:05:57)

jrezneckbhds
Scratcher
500+ posts

Return Block

Support!
cwrivera99
Scratcher
500+ posts

Return Block

turkey3 wrote:

Me_Tis wrote:

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
You already can. Right-click on a custom block, click “edit”, and there are string, number, and boolean inputs.
You obiviously did not look at the images, because that is not at all what he is talking about.

Me_Tis wrote:

It seems that this thread has reached a conclusion. TM_ has created a project to explain it. http://scratch.mit.edu/projects/11829884/


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
I support this.
Maltion
Scratcher
100+ posts

Return Block

Bump. Bringing this up too.
da-ultimate-creater
Scratcher
100+ posts

Return Block

Support if we had the ability to make custom reporters/booleans. Otherwise it would be kind of useless.

Maybe the return block could look like this:

return () :: control cap

I just realized how old this topic is

Powered by DjangoBB