Tips&Tricks – If-Then-Else condition Part II

24 Jul

In my blog post HERE, I showed how you can use data structures along with App Inventor procedure to loop through a set of conditions to check if a user entered value falls within a data-range. The approaches that were discussed will drastically reduce the number if if-then-else statements and will also make maintenance much simpler.

Part II will show you how to check for single values rather than a range of values.

For example, consider the situation where you need to bring-up different web-pages based on user response. For this, the simple approach, as shown below, would be to include a set of if-then-else blocks:


Above approach would require additional “else-if” blocks for adding in more criteria. An alternative to above, would be to use LIST along with PROCEDURE block as shown-below:


Now consider situation where you have to add in more criteria; e.g. provider4, provider5, and so on. Using above approach, you’ll only have to update comparisonCriteria block and there will be no change in any other blocks.

Other approaches includes using two synchronized lists, reading data from file using File component, downloading initial set of data from cloud and so on.


Leave a comment

Posted by on July 24, 2015 in Uncategorized


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: