Tony Firshman wrote:

gdgqler wrote, On 14/11/09 08:15:
On 8 Nov 2009, at 09:44, John Gilpin wrote:

Is there a way of stepping through a BASIC program, line by line, for debugging purposes? If so how?

The way I debug BASIC programs is to use a routine called Puse, which causes a pause.

DEFine PROCedure Puse
 LOcal a$(2)
 OPEN#20,con
 a$=INKEY$(#20,-1)
 CLOSE#20
END DEFine

By placing this inside the program I can see what's happening. For example

2000 Fling: REMark some procedure
2005 Puse:PRINT "Line 2000":Puse

allows me to see if I have gone past line 2000. Pressing any key allows the program to continue (to the next Puse).

You can add a PRINT facility to Puse by:

 DEFine PROCedure(b$)
.
.
  PRINT#20,b$
.
.
END DEFine

This works well even inside compiled BASIC programs.

... and of course further de-bugging info could be added, like printing critical global variables each time.

Right you are. I miss Minerva SuperBasic's "watch variable" facility, eg:

120 WHEN x > 10: PRINT "X is now too big!"
..
130 FOR x = 5 TO 12: PRINT x

will print

5
6
7
8
9
10
X is now too big!
11
X is now too big!
12

Pity it didnt make it into SBasic

Per
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to