(Added info about how it works in 2.0 alpha, though I haven't had a chance to look at it in close detail, so perhaps somebody else could add more)
(Procedures in Scratch: Removed duplicate information.)
Line 4: Line 4:
 
==Procedures in Scratch==
 
==Procedures in Scratch==
 
[[File:Jump Block.png|thumb|A "jump" procedure.]][[File:Jump block with insert.png|thumb|A "jump" procedure with an argument.]]
 
[[File:Jump Block.png|thumb|A "jump" procedure.]][[File:Jump block with insert.png|thumb|A "jump" procedure with an argument.]]
Procedures will be added in [[Scratch 2.0]].<ref>http://blog.scratch.mit.edu/2011/03/scratch-20-progress-report-create-your.html</ref> There will be a "[[My Blocks]]" palette, where procedures in the project are stored.<ref>http://blog.scratch.mit.edu/2012/02/scratch-20-project-page-and-project.html</ref> The procedures will be local to each [[sprite]].<ref>http://scratch.mit.edu/forums/viewtopic.php?pid=719181#p719181</ref> Procedures in Scratch 2.0 will only be [[Stack Blocks]], not Reporter or Boolean block styles. It remains to see whether they will be [[recursion|recursive]] or not. Procedures are expected to take [[arguments]]. Reporter or boolean procedures will not be available in Scratch 2.0, but may be in future versions.<ref>http://scratched.media.mit.edu/discussions/scratch-20/custom-block-types</ref>
+
Procedures will be added in [[Scratch 2.0]].<ref>http://blog.scratch.mit.edu/2011/03/scratch-20-progress-report-create-your.html</ref> There will be a "[[More Blocks]]" palette, where procedures in the project are stored.<ref>http://blog.scratch.mit.edu/2012/02/scratch-20-project-page-and-project.html</ref> This palette also houses a "make a block" button, similar to the "make a variable/list" buttons in [[Data Blocks]]. The procedures will be local to each [[sprite]].<ref>http://scratch.mit.edu/forums/viewtopic.php?pid=719181#p719181</ref> Procedures in Scratch 2.0 will only be [[Stack Blocks]], not Reporter or Boolean block styles. It remains to see whether they will be [[recursion|recursive]] or not. Procedures are expected to take [[arguments]]. Reporter or boolean procedures will not be available in Scratch 2.0, but may be in future versions.<ref>http://scratched.media.mit.edu/discussions/scratch-20/custom-block-types</ref>
 
 
In the Scratch 2.0 alpha, procedures are under a blocks tab entitled "More blocks", in which you have the option to create and name a block, drag it into the [[Scripts Area|scripts area]] and define it.
 
  
 
==Procedures in [[BYOB]]/Snap!==
 
==Procedures in [[BYOB]]/Snap!==

Revision as of 08:02, 24 May 2012

Clock.png This article or section contains information about a feature from a future version of Scratch that is unreleased and is subject to change. Please cite any additional info in order to prevent speculation.

Procedures, also called functions or methods, are a tool in many programming languages, which allow common blocks of code to be grouped and called by a single name. Blocks in Scratch are procedures themselves, as they are blocks of compiled code executed all at once. Procedures have inputs or arguments, which are used to edit the procedure's effect slightly. For example, the "move (10) steps" block has the numerical argument (the bracketed bit) which specifies the distance to be moved: 10 pixels in this case.

Procedures in Scratch

A "jump" procedure.
A "jump" procedure with an argument.

Procedures will be added in Scratch 2.0.[1] There will be a "More Blocks" palette, where procedures in the project are stored.[2] This palette also houses a "make a block" button, similar to the "make a variable/list" buttons in Data Blocks. The procedures will be local to each sprite.[3] Procedures in Scratch 2.0 will only be Stack Blocks, not Reporter or Boolean block styles. It remains to see whether they will be recursive or not. Procedures are expected to take arguments. Reporter or boolean procedures will not be available in Scratch 2.0, but may be in future versions.[4]

Procedures in BYOB/Snap!

Snap!, previously called BYOB (Build Your Own Blocks), is a Scratch modification that allows procedures. Snap!'s procedures allow all 3 types of blocks, with arguments, and also recursion.

Procedures in Squeak

Main article: Squeak Tutorial#Methods

Procedures in Squeak are called methods.

References

  1. http://blog.scratch.mit.edu/2011/03/scratch-20-progress-report-create-your.html
  2. http://blog.scratch.mit.edu/2012/02/scratch-20-project-page-and-project.html
  3. http://scratch.mit.edu/forums/viewtopic.php?pid=719181#p719181
  4. http://scratched.media.mit.edu/discussions/scratch-20/custom-block-types