Making Your Own Block

PG: Lighter edit. Focus on kids' use of structure they've already learned, /using/ what they know. Is this the time for our video to have yet a new background?

On this page, you will create a newgossip response block to make the program feel more like a conversation.
gossip2 reporting 'Guess what. Gabrielle helped Señora'

  1. If it isn't open already, open your U1L2-Gossip project.
  2. Create the gossip response block:
It occurs to me that gossip response is a slightly misleading name. Shouldn't it be response header or something? It doesn't report a complete response. --bh

I think it's ok. If you tell me some gossip, my response might be "Oh, wow!" "Yeah? Well, I heard...", etc. and that's what this block offers. --MF, 7/21/19

Making a New Block

    image of 'Make a block' dialog box with palette with 10 menus (Motion, Looks, Pen, Sound, Lists, Control, Sensing, Operation, Variables, Other) labeled 'Choose a color (a palette)'; a text box labeled 'Type a title for your block.'; three block shape options (puzzle-shaped/'Command', oval/'Reporter', and hexagonal/'Predicate') labeled 'Select a shape.'; two radio boxes (for all sprites, which is checked, and for this sprite only, which is not checked) with no label; and two buttons (OK and Cancel) labeled 'Click OK.'
  1. Create a new block by either clicking make a block button near the end of the palette, clicking the + sign in the top right corner of the palette (shown below), or right-clicking (or control-clicking on a Mac) in an empty spot in the scripting area and choosing "make a block..." (shown below).
    plus sign atop palette make a block option
  2. Choose the color, in this case red for Lists.
  3. Type the title for your block: gossip response.
  4. Select the shape and click OK. For this block, choose the oval reporter shape because you want it to report a value (the chosen response) to another block.

Because you chose the reporter shape, the block editor opens with a report block already attached to the hat block. Whatever input you give to report will become the value reported by your new block.

Coding the Block's Script

  1. Drag in the blocks you need. For your new block, use the list block and item(1) of (). Use the value reported by list as an input to item.
  2. Snap the blocks together. The code's structure will be just like the code inside who, does what, and who2.
  3. Fill all the inputs.
    • For this project, click the down-arrow in item to change "1" to "random".
    • Then fill list with phrases like "Guess what," "I heard," or "Who cares!"
  4. Click OK when you're satisfied.
: Procedures, Reporters, and Commands
AAP-3.A.1, AAP-3.A.2

A procedure is a named sequence of instructions that may take inputs and may report a value. Some languages call procedures methods or functions. Here are two types of procedures you have seen in Snap!:

Debugging

    Pair Programming Swap
    Why don't we combine #3 and #4? --MF, 5/26/20
  1. Test your custom gossip response block by clicking it several times. It should behave like the who, does what, and who2 blocks.
  2. Debug any problems before moving on.
  3. Review how to edit a block in Unit 1 Lab 2 Page 2: Customizing and Debugging, if needed.
  4. Use your new block: Edit gossip 2, and insert gossip response in place of the text "Oh, but...."
    gossip 2 {
    report (join (gossip response) ( ) (who 2) ( ) (does what) ( ) (who) )
}
  5. Test and debug gossip 2 also.
  6. Then test the whole program by clicking script D several times, and fix any bugs.
  7. Save your work