Learning MIT App Inventor: A Hands-On Guide to Building Your Own Android Apps
by Derek Walter, Mark Sherman
Global Variables
Global variables need to be initialized before they can be used. The initialize global block does three things: creates the variable, gives it a name, and sets its initial value.
Choose the initialize block from the Variables built-in menu, and then click in the Name field to replace the word name with a useful name. The initialize block must have an initial value. This is similar to setting a value of a component property in the Designer; you have to put in something for the app to have in that variable when it starts. A variable cannot be truly empty.
Usually, the value given to the initialize block is useful and relevant, such as setting a counter variable to start at zero. Sometimes you just need space for later and you ...
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.
Read now
Unlock full access