Use App Inventor 2 to search from the Big Bang to locate the Massachusetts Institute of Technology (MIT) within the Universe
Abe Getzler
June 2016
Sample run
Start at the Big Bang
We start with a Web Viewer pointing to a web page on The Big Bang, and a List Picker set to show the super clusters that resulted from The Big Bang .
Children of The Big Bang
This List Picker is loaded with the names of the major sub components of the item that was last picked, followed by the trail of prior items, to let the user go back from a poor choice.
After Picking Laniakea Super Cluster
Here we have picked the Laniakea Super Cluster, and the Web Viewer and List Picker are reloaded to show our selection and its possible children.
Program Structure
Designer
There are only three components:
- A Web Viewer to show details of our choice
- A List Picker to show our navigation options
- A File for loading our navigation map.
Screen1.Initialize
At startup time, we start loading our csv formatted navigation map file from the Media Drawer.
Wheres_MIT.csv
Spreadsheet programs make it easy to edit a navigational map file and export it in Comma Separated Value (CSV) format. This map is set up with parent name in column 1, child name in column 2, and child URL in column 3.
Column 2 is our unique key to this table.
File1.GotText
When the csv text map arrives, we save it into a global text variable, in case we need to diagnose it later. Then we send it through a list from csv table block to convert it into a table (list of lists).
The first column of the first row is reserved for the starting point of our tour, the root.
We visit the root.
Global map and map_text
Stack and Root
The stack global will hold a list of all the names of places we have visited, starting at the root, newest at the front (position 1).
Visit
Given the name of the item in our map we want to visit, we first extract the children of that key from our map. We push our key onto our stack at slot 1, look up its URL in our map, and have the Web Viewer show it. We then show our current key in the List Picker, as well as all its children in the stack and the List Picker Elements.
Children
This is a value procedure, returning a simple list of the text values in column 2 of our map where column 1 matches our key.
URL
The URL of a key is the third column of the row in our map that belongs to that key.
Row
The row value procedure returns a simple 3 element list containing a copy of the row in the map that matches the given key in column 2.
ListPicker1.AfterPicking
After the user selects a destination name from the List Picker, we visit that selection.
댓글 없음:
댓글 쓰기