Skip to Content
App Inventor 2, 2nd Edition
book

App Inventor 2, 2nd Edition

by David Wolber, Hal Abelson, Ellen Spertus, Liz Looney
October 2014
Beginner to intermediate
360 pages
9h 3m
English
O'Reilly Media, Inc.
Content preview from App Inventor 2, 2nd Edition

Chapter 20. Repeating Blocks

Figure 20-0.
Repeating Blocks: Iteration

If there’s one thing that computers are good at, it’s repeating things—like little children, they never tire of repetition. They are also very fast and can do things such as process your entire list of Facebook friends in a microsecond.

In this chapter, you’ll learn how to program repetition with special repeat blocks instead of copying and pasting the same blocks over and over. You’ll learn how to send an SMS text to every phone number in a list and how to add up a list of numbers. You’ll also learn that repeat blocks can significantly simplify an app.

Controlling an App’s Execution: Branching and Looping

Repeat blocks cause a program to loop
Figure 20-1. Repeat blocks cause a program to loop

In previous chapters, you learned that you define an app’s behavior with a set of event handlers—events and the functions that should be executed in response. You also learned that the response to an event is often not a linear sequence of functions and can contain blocks that are performed only under certain conditions.

Repeat blocks are the other way in which an app behaves in a nonlinear fashion. Just as if and else if blocks allow a program to branch, repeat blocks allow a program to loop; that is, to perform a set of functions and then jump back up in the code and do it again, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

App Inventor

App Inventor

David Wolber, Hal Abelson, Ellen Spertus, Liz Looney
App Inventor 2 Essentials

App Inventor 2 Essentials

Felicia Kamriani, Krishnendu Roy
Hello App Inventor!

Hello App Inventor!

Carl Simmons, Paula Beer

Publisher Resources

ISBN: 9781491907214Errata Page