There are three Step commands — Step Over, Step Into, and Step Out.
To issue a Step command:
Choose it from the Script menu.
Or, click the button in the toolbar.
The three Step commands differ with respect to where execution will pause afterwards. We’ll use the code in the illustration below to show what the different Step commands mean. In the illustration, we are initially paused at a breakpoint at line 9 (without yet having executed line 9).
Step Into is the simplest. It means, “Execute the current line of code, and then, wherever the path of execution takes you, pause right there, on the next line that would be executed.”
So, in the illustration above, Step Into would cause the script to pause at line 5. Why? Because line 9, where we are paused, calls the pad
handler. So when we execute it, we’ll dive into the pad
handler, and the next executable line where we can pause, in that path of execution, is line 5.
Step Over is similar to Step Into, except that it follows an additional rule, “Don’t pause in a deeper level of the call stack than where you are right now.”
So, in the illustration above, Step Over would cause the script to pause at line 10. Why? Because that’s the next executable line that isn’t at a deeper level. Line 9, where we are paused, calls the pad
handler, which is a deeper level, so we don’t pause until the next executable line after the path of execution has returned from the pad
handler.
Step Out means, “Execute until you come to the next executable line at a higher level of the call stack than where you are right now, and then pause.”
So, in the illustration above, Step Out would cause the script to pause at line 13. Why? We are paused at line 9, in s
’s implicit run handler. We execute to the end of the run handler, which is line 10, and return from s
’s implicit run handler. Now we are at a high level, so we want to pause. In fact, we are in line 12, because that is where s
’s run handler was called. But we don’t pause in line 12, because if we were going to pause there, it would be before executing line 12 and before telling s
to run. So now we’re at line 13.
All of those details are predicated on the supposition that no breakpoints are encountered. Suppose, for example, that there were an enabled breakpoint at line 5 (and assume that Script > Break on Breakpoints is checked, and that this breakpoint has no conditions). The path of execution passes through line 5, so all three commands would do exactly the same thing — pause at line 5. Breakpoints take priority!
Both Step Over and Step Into can be used not only to resume but also to start execution of a script. In this case they both pause before the first executable line of the script.
Both Step Over and Step Into have the same options for executing handlers as the Execute button.