3.6. Running to Line

[<<<] [>>>]

Start the debugger again and without debugging let the program run to the line where the function call starts. To do this the command r should be used.

E:\MyProjects\sb\source\examples>scriba -i dbg debugtest.bas
ScriptBasic debugger, executing
  debugtest.bas
For help type 'h'

----------------------------------------------------- >001. print "hello\n" 002. a = 3 003. 004. sub MyFunction(t) 005. local a,b,c

----------------------------------------------------- #r 14 hello

----------------------------------------------------- 012. end sub 013. >014. MyFunction a 015. 016. a = a + 2

----------------------------------------------------- #_

The command r has one argument, the number of the line to run to. If the argument is missing the program will run until it finishes or until a breakpoint is found.

Now step into the function and step until the first number is printed.

#s

----------------------------------------------------- 002. a = 3 003. >004. sub MyFunction(t) 005. local a,b,c 006.

----------------------------------------------------- #s

----------------------------------------------------- 005. local a,b,c 006. >007. b = t + 2 008. print b 009. print " ",t

----------------------------------------------------- #s

----------------------------------------------------- 006. 007. b = t + 2 >008. print b 009. print " ",t 010. if t > 1 then MyFunction t-1

----------------------------------------------------- #s 5 ----------------------------------------------------- 007. b = t + 2 008. print b >009. print " ",t 010. if t > 1 then MyFunction t-1 011. print " *"

-----------------------------------------------------

Now we want to advance program execution to the line 11 so we issue the command r 11.

#r 11
 34 23 1
-----------------------------------------------------
  009. print " ",t
  010. if t > 1 then MyFunction t-1
 >011. print " *"
  012. end sub
  013.

----------------------------------------------------- #_

You get the numbers printed again, but where are the *? When MyFunction t-1 was called it printed the starts didn't it? The answer is that is did not.

Running to line 11 started to execute the program and stopped the execution as soon the line 11 the first time was about to be executed. Our function called itself with the argument 2 and then even getting deeper with argument 1 before it did not call itself any deeper and execution stopped at line 11.

Quit the program again, start debugging again and first run to line 9, and then issue the command R 11:

#q
Ok... you have said that... quitting...
(0): error &H37:The preprocessor said to abort program compilation or execution.

E:\MyProjects\sb\source\examples>scriba -i dbg debugtest.bas ScriptBasic debugger, executing debugtest.bas For help type 'h'

----------------------------------------------------- >001. print "hello\n" 002. a = 3 003. 004. sub MyFunction(t) 005. local a,b,c

----------------------------------------------------- #r 9 hello 5 ----------------------------------------------------- 007. b = t + 2 008. print b >009. print " ",t 010. if t > 1 then MyFunction t-1 011. print " *"

----------------------------------------------------- #R 11 34 23 1 * * ----------------------------------------------------- 009. print " ",t 010. if t > 1 then MyFunction t-1 >011. print " *" 012. end sub 013.

----------------------------------------------------- #_

This time the program did not stop in the recursive function call.

The command R is similar to command r, but it does not stop at the line in recursive functions.


[<<<] [>>>]