Defining a Variable That Depends on Runtime Elements

Variables are great. Sometimes you can initialize them and include the data as part of the initialization, such as with a hard-coded piece of text (see Figure 6.38). This kind of data is already known before the app starts because it’s right there in the code blocks.

Image

Figure 6.38 A perfectly fine global variable initialization that depends on known information.

However, sometimes you want to fill a variable from data that isn’t definitely known or that is somewhere else, such as in a TextBox. If you try to initialize a variable to include data from a component, it doesn’t work (see Figure ...

Get Learning MIT App Inventor: A Hands-On Guide to Building Your Own Android Apps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.