Troubleshooting Formulas

book list add book to my bookshelf create a bookmark purchase this book online

mastering crystal reports 9
Chapter 4 - Adding Business Logic with the Formula Workshop
Mastering Crystal Reports 9
by Cate McCoy and Gord Maric
Sybex 2003

It can definitely be a challenge to write good code, and in fact, you’ll never get it right the first time. Programmers call the process of finding the errors in their code debugging, a phrase attributed to Grace Hopper, a twentieth-century military computer programmer. There are several things you can do to help yourself write good code and help find errors when they do occur.

Call Stack

The Formula Workshop contains a feature known as the call stack. If there is a problem in your code, the call stack will automatically appear with a drill-down path to show where the error occurred. It returns interim values as part of a call stack, with the line of code on the bottom of the stack being the line that actually encountered the error.

Performance Issues

Crystal Reports provides built-in information on how your report is performing. From the menu, select Report > Performance Information to open the dialog shown in Figure 4.42. Use this dialog to choose between report definition information, saved data specifications, processing time information, and grouping information. You also have the option to save the data to a file, which allows you to return to it at any point.

click to expand
Figure 4.42. Finding performance information

Writing Good Code

The following are a few tips and techniques that will improve the quality of your code and help you become an efficient programmer:

  • Space and format your code well; the easier it is to read, the easier it is to troubleshoot (debug).

  • Code a little, test a little, debug a little, then repeat; it is much easier to debug a little bit of isolated code than a huge set of code statements that might contain multiple errors.

  • Break large coding tasks down into smaller ones, using a function for each task. This will help organize your work and keep you from creating overly complex single functions.

  • Create a special section at the top of your report to use to test values as you’re working on new formulas.

  • Comment your code—you want to be able to read it in a few days!

  • If the code isn’t working, take a break from the computer and write the steps down in English to try to make sense of what you’re doing; often it’s our logic that is at fault, not the code.

  • Finally, have fun with what you’re doing! Writing code is a creative process; sometimes it’s a painful process, but ultimately, you’ll be proud of your work.

Use of content on this site is expressly subject to the restrictions set forth in the Membership Agreement
 
Conello © 2000-2003     Feedback


Mastering Crystal Reports 9
Mastering Crystal Reports 9
ISBN: 0782141730
EAN: 2147483647
Year: 2005
Pages: 217

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net