Build a journal app with three screens: pick a value you showed today, say what you did, then see every entry in a list. A global variable carries your choice from one screen to the next, an array keeps the entries, and a Repeat loop puts them in the list.
Almost every app has more than one screen: sign in, choose, confirm, see your list. Something has to remember what you did on the screen before.
Today's prototype has three screens. In Construct each screen is a layout, with its own event sheet.
Choose: buttons for four values, such as Kindness, Courage, Curiosity and Teamwork (or your school's own values).
Describe: "What did you do to show Courage?", a box to type in, and an Add to my journal button.
Journal: a list of every entry so far, and a button to add another.
How this lesson works: Predict, Try, Investigate, Modify, Make
Predict: Read the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Try: Try it on the board and compare the result with your prediction.
Investigate: Work out why it happens, one step at a time.
Modify: Change the problem on purpose and see what happens.
Make: Make your own problem using what you have learned. Expect a few tries; that is normal.
Make your prediction first. Help opens once you've locked it in.
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Does the choice survive?
TryTry it on the board and compare the result with your prediction.
Try the finished app
This is the finished app you'll build. Each screen shows its own event sheet.
Try it yourselfYour edits are saved in this browser.
Add two entries with different values. Watch Chosen and Journal.Width under the event sheet.
Use the board. This ticks when you get there.
TryTry it on the board and compare the result with your prediction.
Build it: three screens
Screen 1: choose
Start a New project called Values journal.
On Layout 1, insert a title Text, Values journal, and a line below it, Which value did you show today?
Insert four Buttons, one per value, named KindnessButton, CourageButton and so on, with the value as each one's text.
Insert an Array object (it has no picture on the screen). In its Properties set Width to 0, Height 1, Depth 1, name it Journal, and make sure Global is ticked, so it carries on to the other screens.
Screen 2: describe
In the Project panel, right-click Layouts and add a layout. If Construct offers to make an event sheet for it, say yes.
On Layout 2, insert a Text called Question, a Text Input (make it wide), and a Button called AddButton with the text Add to my journal.
Screen 3: the journal
Add Layout 3 the same way. Insert a title Text, My values in action, a List object (make it tall), and a Button called AnotherButton with the text Add another.
Each layout must use its own event sheet: click an empty part of the layout and check its Event sheet property. If a screen's events never seem to run, this is the first thing to check.
Events
In Event sheet 1, add a global variable Chosen, type String (text), starting empty.
Still in Event sheet 1: KindnessButton, On clicked → System, Set value, Chosen to "Kindness", then System, Go to layout, Layout 2. Do the same for each value button.
In Event sheet 2: System, On start of layout → Question, Set text: "What did you do to show "&Chosen&"?"
Also in Event sheet 2: AddButton, On clicked → Journal, Push, back, X axis, value uppercase(Chosen) &": "&TextInput.Text, then Go to layout, Layout 3.
In Event sheet 3: System, On start of layout → List, Clear.
Add a separate event in Event sheet 3: System, On start of layout, then right-click it, Add another condition, System, Repeat, Journal.Width times. Action: List, Add item, Journal.At(loopindex).
AnotherButton, On clicked → Go to layout, Layout 1.
Preview from Layout 1 and add three entries.
InvestigateWork out why it happens, one step at a time.
Lists and loops
Nib's journal only ever shows the latest entry. Click the line where Nib first goes wrong.
ModifyChange the problem on purpose and see what happens.
Count the entries
Add a Text to Layout 3 and set it in the first On start of layout event: "You've added "&Journal.Width&" moments"
MakeMake your own problem using what you have learned. Expect a few tries; that is normal.
Test the flow
Ask someone to add two entries without any help from you. Watch where they pause or click the wrong thing. Then change one thing: a clearer button name, a Back button on screen 2, or an empty-box check before saving.
Lesson done. You've finished every step you need.
Now you can
Make an app with more than one screen and buttons that move between them.
Use a global variable to carry a choice from one screen to the next.
Store entries in an array and show them in a list.
Students build a three-screen journal: choose a value, describe what they did, and see every entry in a list. A global variable (Chosen) carries the choice between layouts, an Array (Journal) stores entries with Push, and screen 3 rebuilds a List from the array with Repeat and loopindex in a separate event from Clear. About 75 minutes.
I can make an app with more than one screen and buttons that move between them.
I can use a global variable to carry a choice from one screen to the next.
I can store entries in an array and show them in a list.
Before class
The values are examples. Use your school's own values if it has them, or let students choose four that matter to them. Entries are personal: students keep the app on their own device and nothing is collected or shared. Keep any class discussion on made-up entries.
Check before class: the Array's Global property. If the array isn't kept between layouts, entries pushed on screen 2 won't be there on screen 3. Step 4 tells students to make sure Global is ticked; confirm the property name in the current editor.
When a layout is added, Construct usually offers to add an event sheet too. If a student has extra or missing sheets, click an empty part of each layout and set its Event sheet property.
Step 12 and 13 must be two separate events. If Clear sits in the same event as the Repeat, it runs on every repeat and only the last entry is left (the Investigate bug).
The journal forgets everything when the preview closes. That's fine for a prototype; saving between sessions (Local Storage) is a stretch.
These steps were written fresh for this site and have not yet been checked click by click in the current editor. Run through them once before class.
Running the lesson
Predict: ask what 'global' might mean before the reveal.
Build it: checkpoint after step 10: does screen 2 show the chosen value? Fix that before arrays.
Investigate: write loopindex 0, 1, 2 under three entries on the board, and point to At(0), At(1), At(2).
Make: pair students from different tables, so the tester hasn't seen the app built.
The hard part (on purpose)
This is the longest build in the course, and the most common failure is a layout using the wrong event sheet, so nothing on that screen happens. Check each layout's Event sheet property before anyone debugs further.
When students get stuck
A screen's buttons do nothing. Ask: Which event sheet does this layout use? Fix: Click empty space on the layout and set its Event sheet property to the sheet with its events.
Screen 3's list is empty. Ask: Is the Journal array Global, and does the Push run before Go to layout? Fix: Tick Global on the array, and keep Push above Go to layout in AddButton's event.
Only the last entry shows. Ask: Are Clear and Add item in the same event? Fix: Move Clear into its own On start of layout event above the Repeat event.
Stretch and support
Stretch: Save the journal between sessions with the Local Storage object (Array AsJSON and Load), or show the newest entry first.
Support: Build screens 1 and 2 as a class first, then let students build screen 3 in pairs.
Where it leads
Next: Creature stats, where one object has many copies, each with its own values.
What each step is for
does the choice survive?: Predicting whether the chosen value reaches screen 2 sets up the move: a global variable keeps its value when the app goes to another layout.
Try the finished app: Using the finished three-screen app first gives a target for the long build and shows the global variable carrying the choice.
Build it: three screens: Building the three layouts, and seeing the chosen value appear on the next screen, settles the prediction and sets up the array and list.
lists and loops: Tracing loopindex and finding Nib's combined event check how the list is built from the array, using the global array the move depends on.
count the entries: Showing the count reuses the array's Width, an existing value, rather than a new variable, which checks students know what the array holds.
test the flow: Watching a user move through three screens is the design half of a prototype: the flow that made sense to the builder isn't always clear to someone else.