1.5.1 How it works
When a program stops moving forward, the engine says exactly why. That reason is called the termination and it is always one of these six:
| Termination | What it means | Can it continue? |
|---|---|---|
completed | The algorithm reached its EndAlgorithm | No: it finished |
failed | A runtime failure stopped it | No |
awaiting_input | A Read needs a value that has not arrived yet | Yes, once it receives it |
awaiting_effect | It is waiting for an answer from a file, clock or network | Yes, once it receives it |
cancelled | Whoever was running it stopped it | No |
limit_reached | It ran out of a statement, memory or depth budget | No |
At the top, the running state. An arrow goes down to a box with the four final terminations: completed, failed, cancelled and limit_reached. Two side arrows lead to the pauses awaiting_input and awaiting_effect, which resume.
The normal case is completed:
ProgramEnds normally
Algorithm Bien
Write "Fin del programa";
EndAlgorithmOutput
Fin del programa
The program finishes normally.
A runtime failure stops the program at the exact statement. What was already written is kept:
ProgramEnds with a failure
Algorithm Falla
Define divisor As Integer <- 0;
Write "Antes del fallo";
Write 10 Div divisor;
Write "Esto nunca se escribe";
EndAlgorithmOutput
Antes del fallo
Diagnostics
divisionByZero· error · 4:12 · Division by zero
The program finishes with an error.
If a Read receives no value, the program pauses. The editor asks you for the data and the run continues where it stopped:
ProgramWaits for input
Algorithm Espera
Define edad As Integer <- 0;
Write "¿Cuántos años tienes?";
Read edad;
Write "El año que viene tendrás ", edad + 1;
EndAlgorithmOutput
¿Cuántos años tienes?
The program is left waiting for input.
In short
- Six possible terminations; only
completedmeans everything went well. - A failure stops the program at the exact statement and keeps what was already written.
awaiting_inputandawaiting_effectare pauses that resume.