Lesson Plan: Foreach Iteration and the NoteTaking App

This lesson introduces the foreach block in the context of displaying a list of notes in a NoteTaking app.

1. Open the NoteTaking app built in previous lesson. How is the list of notes displayed?

The notes are displayed in the default manner and appear arbitrarily without line breaks for items, etc.

2. Introduce foreach and how it does something to each item in a list.
  • for each item in our list we want to display it in label along with an endline (introduce \n as the endline)
  • Replace simple display blocks in previous app with a foreach that displays each entry on a separate line.
  • Introduce make text as a way to concatenate text together.
  • Note how the label is set to its previous value (itself) concatenated with \n and the "next item"
  • Demonstrate that notes now appear on separate lines
3. Activity: Modify the Notes app so that:
  • the notes appear on separate lines, as demonstrated
  • the notes appear most recently added (at top) to least recently added
  • The data appears with the note
    • need clock component and each item is a make text with note, colon, and now.



© AppInventor.org 2012