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.

424 Day 11<br />

Q I have a variable that I want to view <strong>in</strong> both decimal and hexadecimal format.<br />

Can I do that with the Watch List?<br />

A Yes. First add the variable to the Watch List. When the Watch Properties dialog<br />

box comes up, choose the Decimal view<strong>in</strong>g option. Now add the variable aga<strong>in</strong>,<br />

but this time choose the Hexadecimal view<strong>in</strong>g option. Both items will be listed <strong>in</strong><br />

the Watch List, one <strong>in</strong> decimal format and the other <strong>in</strong> hex format.<br />

Q I’m try<strong>in</strong>g to add the Width property of a component on my form to the Watch<br />

List. I get some strange error like, “Po<strong>in</strong>ter to structure required on left side of<br />

someth<strong>in</strong>g or another.” What am I do<strong>in</strong>g wrong?<br />

A You can’t <strong>in</strong>spect a property of a component us<strong>in</strong>g the Watch List. You can,<br />

however, <strong>in</strong>spect the component us<strong>in</strong>g the Debug Inspector and locate the FWidth<br />

data member rather than the Width property. (The FWidth data member holds the<br />

value of the Width property.)<br />

Q I want to stop at a breakpo<strong>in</strong>t only when a variable reaches a certa<strong>in</strong> value and<br />

after the breakpo<strong>in</strong>t has been hit a certa<strong>in</strong> number of times. Can I do that?<br />

A Sure. Enter a conditional expression <strong>in</strong> the Condition field of the Edit Breakpo<strong>in</strong>t<br />

dialog box and a value <strong>in</strong> the Pass Count field. When the condition is met for the<br />

number of times <strong>in</strong>dicated by the pass count, the program will pause at the<br />

breakpo<strong>in</strong>t.<br />

Q I’m stepp<strong>in</strong>g through my code, and I get to a function <strong>in</strong> my program that I<br />

want to debug. When I press F8, the execution po<strong>in</strong>t jumps right over the<br />

function <strong>in</strong>stead of go<strong>in</strong>g <strong>in</strong>to it. What do I do to get <strong>in</strong>to that function?<br />

A When the execution po<strong>in</strong>t is on the l<strong>in</strong>e where the function is called, press F7<br />

(Trace Into) <strong>in</strong>stead of F8. Now you can step through the function a l<strong>in</strong>e at a time.<br />

Q When I step through my code, the execution po<strong>in</strong>t jumps all over the place<br />

rather than proceed<strong>in</strong>g through my code a l<strong>in</strong>e at a time. What causes that?<br />

A In a word: optimization. If you want to be able to debug your program one source<br />

code l<strong>in</strong>e at a time, sequentially, turn off all optimizations and then do a Build All<br />

to rebuild the project.<br />

Q I step through a function l<strong>in</strong>e by l<strong>in</strong>e. Sometimes when I get to the clos<strong>in</strong>g<br />

brace of the function I press F8 one more time and noth<strong>in</strong>g happens. Why?<br />

A Because when that particular function returns, your program has noth<strong>in</strong>g more to<br />

do, so it goes back <strong>in</strong>to its idle state. Essentially, there is no more code to step<br />

through at that po<strong>in</strong>t, so the debugger returns control to the program be<strong>in</strong>g<br />

debugged.<br />

Q How do I use the CPU View when debugg<strong>in</strong>g?<br />

A Just choose View | CPU from the ma<strong>in</strong> menu to display the CPU View. Know<strong>in</strong>g<br />

what to do with the CPU View, however, is another matter entirely!

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

Saved successfully!

Ooh no, something went wrong!