next up previous contents
Next: Using Breakpoints Up: Stepping Through Your Script Previous: Displaying Information

Examples: Using the n Command

The n command lets you step over function calls in your scripts. This command saves you time because you won't need to single-step through every line of every function. The program below has three functions defined and three function calls and is used to demonstrate the n command.

1:      sub a {

2:          print("This is function a\n");

3:      }

4:

5:      sub b {

6:          print("This is function b\n");

7:      }

8:

9:      sub c {

10:         print("This is function c\n");

11:     }

12:

13:     a();

14:     b();

15:     c();

First, let's see the regular path of execution that takes place using the s command:

13:     a();

2:          print("This is function a\n");

This is function a

14:     b();

6:          print("This is function b\n");

This is function b

15:     c();

10:         print("This is function c\n");

This is function c

If the n command is used instead of the s command, the path of execution stays the same. However, you are prompted after each function call. The lines inside the function are still executed, however.

13:     a();

This is function a

14:     b();

This is function b

15:     c();

This is function c

By switching between the s and n commands, you can decide which functions to step into and which to step over.



dave@cs.cf.ac.uk