2017년 3월 31일 금요일

Where’s MIT?


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

The Big Bang.png
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

After The Big Bang.png


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

Laniakea Supercluster.png
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

Designer.png


There are only three components:
  1. A Web Viewer to show details of our choice
  2. A List Picker to show our navigation options
  3. A File for loading our navigation map.


Screen1.Initialize

Screen1_Initialize.png


At startup time, we start loading our csv formatted navigation map file from the Media Drawer.


Wheres_MIT.csv

Microsoft Excel - Wheres_MIT.csv.png


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

File1_GotText.png
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

global map and map_text.png

Stack and Root

stack and root.png


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

visit.png
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

children.png
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



URL.png
The URL of a key is the third column of the row in our map that belongs to that key.


Row

row.png
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

ListPicker1_AfterPicking.png
After the user selects a destination name from the List Picker, we visit that selection.


All the blocks



See this app in The Gallery:


댓글 없음:

댓글 쓰기