12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

402 Day 11<br />

TIP<br />

The fact that conditional breakpo<strong>in</strong>ts slow down program execution<br />

can work <strong>in</strong> your favor at times. If you have a process that you want to<br />

view <strong>in</strong> slow motion, set one or more conditional breakpo<strong>in</strong>ts <strong>in</strong> that<br />

section of code. Set the conditions so that they will never be met and<br />

your program will be slowed down but not stopped.<br />

The Run to Cursor Command<br />

There is another debugg<strong>in</strong>g command that deserves mention here. The Run to Cursor<br />

command (found under the Run menu on the ma<strong>in</strong> menu and on the Code Editor speed<br />

menu) will run the program until the source l<strong>in</strong>e conta<strong>in</strong><strong>in</strong>g the edit<strong>in</strong>g cursor is reached. At<br />

that po<strong>in</strong>t the program stops as if a breakpo<strong>in</strong>t were placed on that l<strong>in</strong>e.<br />

Run to Cursor acts like a temporary breakpo<strong>in</strong>t. You can use this command rather than<br />

sett<strong>in</strong>g a breakpo<strong>in</strong>t on a l<strong>in</strong>e that you want to immediately <strong>in</strong>spect. Just place the cursor on<br />

the l<strong>in</strong>e you want to break on and choose Run to Cursor (or press F4). The debugger behaves<br />

exactly as if you had placed a breakpo<strong>in</strong>t on that l<strong>in</strong>e. The benefit is that you don’t have to<br />

clear the breakpo<strong>in</strong>t after you are done debugg<strong>in</strong>g that section of code.<br />

Watch<strong>in</strong>g Variables<br />

So what do you do once you’ve stopped at a breakpo<strong>in</strong>t? Usually you will stop at a breakpo<strong>in</strong>t<br />

to <strong>in</strong>spect the value of one or more variables. You might want to ensure that a particular<br />

variable has the value you th<strong>in</strong>k it should have, or you may not have any idea what a variable’s<br />

value is and simply want to f<strong>in</strong>d out. The Watch List allows you to do that.<br />

The function of the Watch List is pretty basic: It allows you to <strong>in</strong>spect the values of variables.<br />

This simple but essential feature often gets overlooked because a lot of programmers don’t<br />

take the time to learn to use the debugger fully. You can add as many variables to the Watch<br />

List as you like. Figure 11.4 shows the Watch List dur<strong>in</strong>g a debugg<strong>in</strong>g session.<br />

Figure 11.4.<br />

The Watch List<br />

<strong>in</strong> action.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!