Debugging
The code below provides an opportunity to use the debugging facility. The
code opens a file, sets a counter to 1 and then reads the records in the file
and increments the counter. To check that the counter produces the correct value
we can use the debugger as follows:
- Check the number of records in the file, which should be set to the number
of records + 1.
- Click in the gutter to the left of the code opposite the line 'inc(next_cons)'.

- Choose View/Debug Windows/Watches (Ctrl/Alt/W).
- Press F9 to run the code, which will stop at the breakpoint you just set.
- from here press F8 to step through the code one line at a time.
- As the line 'inc(next_cons)' is executed the value in the watch window
will change as the records are read and the counter is incremented.



The file here contained 2 records so the outcome of next_cons=3 is what we
want.
Back to Delphi Menu