Skip to main content

Control Flow & Logic

Decision-making and iteration turn a linear list of blocks into a real program.
This tutorial shows how to:

  • branch with if / else if / else
  • repeat work with repeat, repeat while and for each
  • pause or exit a flow with wait and return
  • build conditions with the Logic operator palette

(Block basics are covered in earlier pages; only new behaviour is explained here.)


1 · The IF Block

1.1 Adding an IF

Drag Logic ▸ if from the Toolbox into the Script panel.
The block appears with:

  • a Condition field
  • one container zone labelled then
  • a blue +else if link
  • a blue +else link

1.2 Editing the Condition

  1. Click ✎ on the IF header.
  2. In the Condition field drag an operator—e.g. Logic ▸ == equals.
  3. Fill the left and right sides (numbers, variables or nested operators).
  4. Ok to exit Edit mode.

The IF now evaluates to true or false at run-time.

1.2 Editing the Condition

  1. Click on the IF header to enter Edit mode.
  2. Drag Logic ▸ == equals into the Condition field.
    • The operator block appears as a small capsule containing only the == symbol (no header) and text inputs on either side.
  3. Drag values—numbers, variables, or even other operator blocks—into the left and right slots of the capsule. Just to see that it works, try 1 == 1.
  4. When the expression is complete, Click the == symbol to reveal its ✔ Ok and 🚫 Cancel buttons.
  5. Click ✔ Ok on the operator capsule, then Ok on the IF block to leave Edit mode.

The IF will now evaluate the expression and run its zones based on whether it resolves to true or false at run-time.

1.3 Adding Branches

  • +else if inserts another conditional zone. You can add as many as you like.
  • +else inserts a final fall-through zone (only one allowed).

Each zone is its own container—drop blocks inside in Drag mode.

1.4 Execution Order

At run-time:

  1. The IF evaluates the first Condition.
  2. The first zone whose condition is true executes; its blocks receive a blue outline.
  3. All following zones are skipped.
  4. If no condition is true and an else exists, that zone executes.

2 · Loop Blocks

2.1 repeat

Found under Flow ▸ repeat

  • Field: Number of repetitions (numeric editor).
  • The interior container executes exactly that many times.

2.2 repeat while

Found under Flow ▸ repeat while

  • Field: Condition (same editor as IF).
  • Iterates while the condition remains true.
  • The condition is re-evaluated before every cycle.

2.3 for each

Found under Flow ▸ for each

  • Field: List or dictionary (drop-down).
  • Iterates once per element.
    • For lists the current item value is exposed inside the loop (via the variable item).
    • For dictionaries the current key is exposed (same variable name).

2.4 Loop behaviour during execution

  • The container’s outline turns blue on each iteration.
  • Press ⏸ Pause to halt in the middle of a long loop; press it again to resume.
  • There is no break or continue yet—run the full cycle or stop manually.

3 · Flow Utility Blocks

BlockPurposeLocation
waitPauses execution for a specified number of seconds.Flow ▸ wait
returnStops execution of the current flow immediately.Flow ▸ return

Both are single-line blocks (non-containers).
return leaves any enclosing loops or IF zones without error.


4 · Logic Operator Palette

Operators live under Logic in the Toolbox.
They are blocks in their own right and can be nested inside conditions or parameter fields.

4.1 Comparison operators

  • == equals
  • != does not equal
  • < less than
  • > greater than
  • <= less than or equal to
  • >= greater than or equal to

4.2 Boolean literals & combinators

  • true, false
  • and, or, not

4.3 Building complex expressions

  1. Drag an outer operator (e.g. and) into a Condition field.
  2. Fill each side with further operators, variables or constants.
  3. Continue nesting until the expression matches your need.

There is no enforced depth limit; keep things readable by breaking work into multiple IFs where sensible.


5 · Quick Practice: FizzBuzz Lite

  1. Create a variable n with value 1.
  2. Add Flow ▸ repeat set to 10 iterations.
  3. Inside the loop place an if block.
  4. Build the condition n % 2 == 0 using == equals and Math ▸ remainder (from the Toolbox).
  5. In the then zone drop Message ▸ write to console and set text to even.
  6. After the IF, add Data ▸ increment and target n.
  7. ▶ Play — the console prints even for numbers 2, 4, 6, 8, 10.

You have now combined loops, logic and data mutation.


6 · Recap

  • if / else if / else let you branch.
  • repeat, repeat while and for each provide iteration.
  • wait and return control timing and early exit.
  • The Logic palette supplies comparison and boolean operators that can be nested freely.