Lesson 7 of 18
Using the Debugger
In this lesson
Roy Osherove puts a break point inside the iteration and, in the stopped state, adds watches for the variable that collects the inputs, the full path and the current input file name. He steps through the actions with F10 and watches the values change, which makes complicated scripts easier to debug.
Transcript
[00:02] (external link, opens in new tab) Let's look at a simple example of debugging for something like this. I want to show some of the features of the simple debugger which is still pretty cool. So let's say that we have a problem where we're not appending things correctly or anything. We can put break points inside iterations. For example, here I can just click here, put a break point here and actually just start running. Now, the first time it gets to the break point, now I'm actually in a stopped state. And now I can go down here into the watch window.
[00:33] (external link, opens in new tab) And now I can add a watch. And that watch could be any of the parameters. For example, I can look for the V all inputs. And I can see that it doesn't have a current value. And I can let's say add watch for the full path. Let's say where are you? Full path of generation
[01:04] (external link, opens in new tab) And generation directory. We can add both of these. You can see this is the full path and generation directory. And let's add another. We'll call it the temp the temp input file name just so we can see how things are going. So we're actually going through this file right now. Now I can actually continue onwards off to the next stage. I can step through. So I can press F10 or just click here.
[01:36] (external link, opens in new tab) And now the value of V all input you see it became green for a second is this value. So I can step forward and you can see things turn change here slowly but surely. So I can see the previous value previous value two when there is one and now I have this is the previous value one. So this is the current value. Sorry, this is the current value.
[02:06] (external link, opens in new tab) This is the one just before it. This is the one just before it. Okay. So we're looking at this file, but we used to have this file and that one just before it. And we can step through again append. And we can see that the current value is now different. I can click it. I can see the current value and the new value which contains the two sentences. So this is pretty good. If you're doing complicated stuff, this is this is the part where things become easier to debug.
[02:41] (external link, opens in new tab) So I can just step on through. You can see how things keep changing. The input file name keeps changing etc. Let's see. You can see V all inputs changes again. And now we're basically done.