mit-scratch

MIT Scratch Function Block


I'm going through a "Learn to Program with Scratch" book with my kid. One of the exercises is asking to create a "function block" that uses some simple formula. They don't explain what is "function block" in the book or I might've missed it. I couldn't find any info about it either. Could anyone tell me what is this and may be give an example? Thanks!


Solution

  • A function block is actually a custom block. This is the purple More Blocks palette of scratch. In the palette, you can click Make a Block which allows you to define your own block/method. You can name the block and also click on options to add parameters so you can insert parameters. You can drag the dark blue parameter in the define header of the block into the relevant block for a variable. E.g. Define[DrawSquare (size)] // where (size) is the blue circle and parameter. repeat (4) move (size) steps turn 90 degrees

    To put the parameter in, you must drag the (size) in the definition header into the white space for move () steps.

    Once you have created your block, you can add the block to the program from the same palette. You can insert your arguments in the parameters which are the white spaces.