How do I make if conditions using and blocks in mit app inventor

Im trying to make a project and I need to build if statements, but I need to build 1125 of them. My teacher says that I can do this easier with and blocks, but I dont know how to. Can anyone pls help

This just sets alarm bells ringing! Why do you need over 1000 if/else condition statements ?

Well, I have a questionare with 5 questions, each with 3 to 4 options, and I have to code a way to say that if I select this specific code of options, I should get this specific answer, for each and every one of the 1000+ if statements.

Currently, my code looks like this. This is just 1 piece.

This

image

is also a worry

Why is that. Please elaborate. I have used that because without some kind of delay, my data is not saving in a google sheets, which I need.

Read the FAQ

I am still thinking about your original question.....

ok, thank you very much.

Are A1-A5 fixed lists, or are A2-A5 list contents dependent on the one above?

All the contents are from the dropdown menu. Each one is independent. The way I have written this code is (If A1 = answer1, then check if A2=answer2, etc, until it says that this statement matched all that the user had said )

This app looks like a quiz app.

On the other hand, if some questions depend on answers to prior questions

  • What is your gender?
    • (If female) how many babies have you birthed so far?

try this sample app:

Yes, my project is a quiz app. This is the file for it.
FindYourSport_Version_6_copy_copy.aia (527.4 KB)

None of my questions rely on each other

The basic idea here is to encode all these options into tables, and let the app work only off the tables and user selections made from the tables.

Here is another table driven app:

A sample Google Sheets app

Notice how it has events to acknowledge completions, not delays.

This is a very good idea, but is it time consuming, as I only have 3 more days to finish my app. I have to present it at my regional science fair competition, so I need the app to show an answer for every single possible outcome, as more than 100 people are going to be testing my app

Nice thing about loading your data from a shreadsheet: Multiple people can add rows to it, to beat a deadline.

Ok, thank you for your help

If it was me, I would probably generate a list containing all the permutations, and load this list into an sqlite.db. Then query the database for the answer. You would need an extension to access the sqlite instance in android.

You could do the same on google sheets, and query there, using the gviz query syntax.

Here is one way to do with @ 120 blocks

generateMegaList.aia (4.7 KB)

image

3 Likes