If anyone here is familiar with AppInventor....

0
down vote
favorite

I have a database of events in AppInventor containing information such as location, description, and tags.

I want to include a search by location screen of an app where the user clicks the button, and the app shows events (taken from the database) that are in the same town as the user. I know AppInventor has a built in location block.

Do you think it is the right course of action to store the database contents into a list, where each index is a value in the database, and then compare the location index with the location of the user? Is this a good sort of pseudo-code for this?

And if this is so, how would I display those search results to the screen?

Thank you.

To create a search by location screen in AppInventor, you can follow the following steps:

1. Storing the Database Contents: Start by retrieving the events data from the database and storing it into a list. You can use the "list from csv table" block to convert the database contents into a list format.

2. Comparing the Location Index: Once you have the events stored in a list, you can iterate through each event and compare its location index with the location of the user. Use a loop block (e.g., "for each item in list") to iterate through the events list. Inside the loop, use an "if" statement to compare the location index of each event with the user's location.

3. Displaying Search Results: To display the search results on the screen, you can use a "list viewer" or a "grid view" component. Create a new list where you will store the events that match the user's location. Inside the loop (from step 2), if the event's location matches the user's location, add it to the new list using the "add items to list" block. Connect this new list to the "elements" property of the list viewer or grid view component to display the search results on the screen.

Here's a sample pseudo-code to help you understand the logic:

1. Get database contents and store them into a list
2. Iterate through each event in the list
- Get the event's location index
- Compare it with the user's location
- If they match, add the event to a new list
3. Display the new list of search results on the screen

Note: Remember to include error handling, such as checking if the location block is supported by the user's device, and handling cases where the user's location is not found.

I hope this helps! Let me know if you have any further questions.