Debug Your Code in VisuAlg Step by Step

Run one line at a time, set breakpoints, read the variables panel and decode common error messages.

Updated October 1, 20266 min read
Monitor showing VisuAlg step-by-step execution with the current line highlighted

The feature that made VisuAlg famous in classrooms is its visual execution. You can watch the program run line by line while every variable updates beside the code. Learning these tools turns debugging from guesswork into observation.

Run modes

KeyAction
F9Run the whole algorithm
F8Step by step: run one line, then pause
F5Toggle a breakpoint on the current line
Ctrl+F2Stop execution

Shortcuts can vary slightly between releases; check the Run menu (Executar) in your copy if a key does nothing.

Step by step in practice

algoritmo "soma_ate_5"
var
   i, soma: inteiro
inicio
   soma <- 0
   para i de 1 ate 5 faca
      soma <- soma + i
   fimpara
   escreval(soma)
fimalgoritmo

Press F8 repeatedly. The current line is highlighted and the variables panel shows SOMA growing 1, 3, 6, 10, 15 while I counts up. If the final value is wrong, you will see exactly which pass broke it.

Breakpoints

In long programs, stepping from the first line is slow. Place the cursor on a suspicious line and press F5 to set a breakpoint. Run with F9 and execution pauses there, then continue with F8.

Timed execution

The timer command and the timed run option slow the program down so you can watch it without pressing keys. It is a great way to present an algorithm to a class.

Reading common errors

Generating test data

Typing input during every test is tiring. Use aleatorio on before leia commands to fill variables with random values, and aleatorio off to return to manual input.

Before stepping through code, write down what you expect each variable to hold. The first line where reality differs from your expectation is where the bug lives.

Using a Mac or Linux machine? See how to run VisuAlg on Linux and macOS.

More VisuAlg guides