Intermediate
Traditional languages use if/else, switch,
and while. Phograph handles conditional logic differently: through
multiple cases and control annotations.
A method can have more than one case. Each case is a separate dataflow diagram. When the method is called:
nextCaseOnFailure annotation and it
fails (produces false), execution jumps to case 2.
Think of cases like pattern-matching clauses or if/elif/else branches,
but each branch is a complete visual graph.
When a method has multiple cases, a bar at the top of the canvas shows “Case 1 of 3” with arrow buttons. You can also navigate with the Class Browser sidebar.
An annotation is a badge on a node that tells the engine how to
handle success or failure. The most important annotation is
nextCaseOnFailure: if this node outputs false, abandon
this case and try the next one.
Common annotations:
| Annotation | Meaning |
|---|---|
nextCaseOnFailure | If this node fails, try the next case |
continueOnFailure | If this node fails, skip it and keep going |
terminateOnSuccess | If this node succeeds, stop (used for loop termination) |
terminateOnFailure | If this node fails, stop the loop |
Look at the Fibonacci example’s fib method, case 1:
The <= node compares n to 1. It has the
nextCaseOnFailure annotation (shown as a badge on the node).
n <= 1 is true: case 1 succeeds, returns n directly.n <= 1 is false: case 1 fails, execution jumps to case 2.Case 2 is the recursive case: it computes fib(n-1) + fib(n-2).
A node fails in Phograph when:
false and has a control annotation.
Without an annotation, a false output is just a normal Boolean value.
The annotation is what gives it control-flow meaning.
if statement tests a boolean but discards
it. In Phograph, the match node both tests and passes data through. The
“successful” path is the normal data flow; failure diverts to the
next case. Data keeps flowing — no values are lost.
For simple conditionals within a single case, Phograph has an if
primitive with 3 inputs: condition, then-value,
else-value. It outputs whichever value corresponds to the condition.
Create a method my-abs (1 input, 1 output) using two cases:
n >= 0 with nextCaseOnFailure.
If true, return n unchanged.0 - n and return it.my-abs(-5) from main. Result should be 5.my-abs(3). Should return 3.max2 (2 inputs, 1 output).>= input 1 with nextCaseOnFailure.
If true, return input 0.max2(3, 7) → 7.max2(10, 4) → 10."positive"
or "negative" using the if primitive.0 with >=."positive", and "negative" into if.nextCaseOnFailure is the most common: “if this test fails, try the next case.”if primitive handles simple conditionals inline.while or for.