P Witte wrote:

John Gilpin wrote:
<>
Is there a way of stepping through a BASIC program, line by line, for debugging purposes? If so how?

You could try something like this:

I wrote a somewhat more sophisticated trace program in the early days, but it relies on the SuperBasic variables to do its stuff. That no longer works in SBasic. So, just because I felt like it, I wrote a new version this evening. It is very simplistic, but should be adequate for testing simple boot scripts and the like. Alter to suit your style:

100 REMark Simple TRACE V3.00
110 REMark pjwitte 20091109
120 :
130 inp$ = 'win1_someprogram_bas'
140 oup$ = 'ram1_test_bas'
150 c% = 0:  REMark Trace channel
160 t% = -1: REMark Timeout
170 :
180 ci% = FOP_IN(inp$): ERT ci%
190 co% = FOP_OVER(oup$): ERT co%
200 :
210 REPeat
220  IF EOF(#ci%): EXIT
230  INPUT#ci%; l$
240  l% = l$
250  s% = (' ' INSTR l$)
260  l$ = l$(s% + 1 TO)
270  IF OK THEN
280   PRINT#co%; l%! 'T.'! l%; ':'! l$
290  ELSE
300   PRINT#co%; l%! l$
310  END IF
320 END REPeat
330 :
340 PRINT#co%; l% + 1! 'STOP: REMark TRACE'
350 PRINT#co%; l% + 2! 'DEFine PROCedure T.(n%)'
360 PRINT#co%; l% + 3! 'LIST#'; c%; '; n% : PAUSE'! t%
370 PRINT#co%; l% + 4! 'END DEFine T.'
380 CLOSE
390 :
400 DEFine FuNction OK
410 IF ('def ' INSTR l$) = 1: RETurn 0
420 IF ('define ' INSTR l$) = 1: RETurn 0
430 IF ('loc ' INSTR l$) = 1: RETurn 0
440 IF ('local ' INSTR l$) = 1: RETurn 0
450 RETurn 1
460 END DEFine OK
470 :

NB! Only SBasic accepts procedures and variables containing a dot, so alter accordingly for SuperBasic!

To test it try using the program as its own input!

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

Reply via email to