Students rebuild the playlist as a table: Songs, with the fields title, artist and length (a number field), made in App Builder's sidebar spreadsheet. A Table object shows it; Add a row takes one value per field; clicking a row removes it with Remove row ClickedIndex. The Check traces row numbers after a removal and asks why a table can't split a song.
Open these in Waypoints Prepare with one click. To share a file another way, copy its address and paste it into Load URL, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.
Try 5 min · Build 1–4 30 min · Check 8 min · Make it yours 15 min
Tables are an App Builder Level 4 feature; these lessons open App Builder at Level 4.
A table is a list of records: each row is one record, each column a field. Field types matter: length is a number so it can be added up (next lesson) and sorted by size (lesson 5). int(LengthInput.text) turns the typed text into a number; a number field also accepts text that is a number.
Removing a row renumbers the rows below it, as a list does.
On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.
One row per thing (a record), one column per detail (a field). Numbers can be added up and sorted by size.
Three students each hold a card for one song (title, artist, length). Remove the middle song: the third student steps up and becomes row 2.
The whole card moves: a title can't leave its artist behind. Rows renumber, as list items do.
Making the table: rename the first field, add fields, change length to Number. The sidebar is narrow; the field's own menu (click its name) does rename, type and delete.
| What you will see | A question to ask | The fix |
|---|---|---|
| The Table object says Choose a table in Properties. | Which table does SongTable show? | Click SongTable on the Design tab and set Shows table to Songs. |
| Add a row shows a box for name, not title. | Did the first field get renamed? | Click the field's name in the sidebar, Rename, and call it title; the action's boxes follow. |
| A message says length holds numbers. | What was typed in the Minutes box? | Type a number such as 4, or use int(LengthInput.text). |
One possible solution for each task. Other correct programs are fine.
{"version":1,"name":"Playlist table","device":"web","features":{"level":4},"variables":[{"name":"Songs","table":{"fields":[{"name":"title","type":"text"},{"name":"artist","type":"text"},{"name":"length","type":"number"},{"name":"genre","type":"text"}]},"value":[{"title":"Blue Sky","artist":"Kai","length":3,"genre":""},{"title":"Arc","artist":"Mo","length":5,"genre":""}]}],"screens":[{"id":"home","name":"Home","objects":[{"name":"Title","kind":"text","instanceVars":[],"instances":[{"id":"h1","x":24,"y":16,"w":500,"h":40,"text":"My playlist","visible":true,"vars":{}}]},{"name":"TitleLabel","kind":"text","instanceVars":[],"instances":[{"id":"l1","x":24,"y":64,"w":60,"h":36,"text":"Title","visible":true,"vars":{}}]},{"name":"TitleInput","kind":"input","instanceVars":[],"instances":[{"id":"i1","x":84,"y":60,"w":170,"h":42,"text":"","visible":true,"vars":{}}]},{"name":"ArtistLabel","kind":"text","instanceVars":[],"instances":[{"id":"l2","x":268,"y":64,"w":60,"h":36,"text":"Artist","visible":true,"vars":{}}]},{"name":"ArtistInput","kind":"input","instanceVars":[],"instances":[{"id":"i2","x":328,"y":60,"w":150,"h":42,"text":"","visible":true,"vars":{}}]},{"name":"LengthLabel","kind":"text","instanceVars":[],"instances":[{"id":"l3","x":492,"y":64,"w":70,"h":36,"text":"Minutes","visible":true,"vars":{}}]},{"name":"LengthInput","kind":"input","instanceVars":[],"instances":[{"id":"i3","x":566,"y":60,"w":70,"h":42,"text":"","visible":true,"vars":{}}]},{"name":"GenreLabel","kind":"text","instanceVars":[],"instances":[{"id":"l4","x":24,"y":108,"w":60,"h":36,"text":"Genre","visible":true,"vars":{}}]},{"name":"GenreInput","kind":"input","instanceVars":[],"instances":[{"id":"i4","x":84,"y":104,"w":170,"h":42,"text":"","visible":true,"vars":{}}]},{"name":"AddButton","kind":"button","instanceVars":[],"instances":[{"id":"b1","x":650,"y":58,"w":130,"h":46,"text":"Add song","visible":true,"vars":{}}]},{"name":"SongTable","kind":"table","instanceVars":[],"instances":[{"id":"T1","x":24,"y":160,"w":560,"h":280,"text":"","visible":true,"vars":{},"source":"Songs","columns":""}]},{"name":"Hint","kind":"text","instanceVars":[],"instances":[{"id":"t1","x":24,"y":450,"w":560,"h":30,"text":"Click a song to remove it.","visible":true,"vars":{}}]}],"events":[{"id":"e1","else":false,"conds":[{"type":"onClicked","target":"AddButton"}],"actions":[{"type":"tableAdd","table":"Songs","values":{"title":"TitleInput.text","artist":"ArtistInput.text","length":"int(LengthInput.text)","genre":"GenreInput.text"}}],"children":[]},{"id":"e2","else":false,"conds":[{"type":"onItemClicked","target":"SongTable"}],"actions":[{"type":"tableRemove","table":"Songs","index":"ClickedIndex"}],"children":[]}]}]}
Open task: any program that does what the step asks.
Stretch: Use Columns to show to hide length on the screen. Does the table still keep it?
Support: Make the table together on the projector; pairs build the events.
A table Books has the fields title, author and pages. What does one row hold, and what does item(Books, 3).author give?
One row holds one book's title, author and pages. item(Books, 3).author is the author of the third book.
Next: Records and fields: read one field of a row, add up a column, find the longest song.