Delphi Clinic C++Builder Gate Training & Consultancy Delphi Notes Weblog Dr.Bob's Webshop
Hubert Klein Ikkink (aka Mr.Haki) - Communications Officer
 Mr.Haki's JBuilder Jar #14
See Also: JBuilder Papers

Arrays and Debugging
Suppose we have the following piece of code in our program:

   int ARRAY_LENGTH = 200;
   double[] doubleArray = new double[ARRAY_LENGTH];
   for (int i = 0; i < ARRAY_LENGTH; i++) {
     doubleArray[i] = Math.random();

This segment of code initializes an array of doubles with size 200. Then the array is filled with random number generated by the Math.random() method.

If we want to debug this piece of code and look at the 151th value of the array then we have a problem. The following image shows JBuilder doesn't show any values of the array above index 99 in the debug window:

Inspecting array during debug session

So how are we suppose to see the 151th value of the array? Luckily it is possible and very easy to do this. In the debug window we must select the doubleArray variable and right-click with the mouse:

Right-clicking the array variable

From the popup menu we select the first menu item Adjust range.... This opens a dialog box in which we can define the range of the array we want to inspect and see in the debug window:

Adjust range dialog box

If we change the start index to 150 and the count to 50, we can inspect the last 50 items in the array. And we can now look which value the 151th item in the array has:

Adjust range dialog box

This webpage © 1997-2009 by Bob Swart (aka Dr.Bob - All Rights Reserved.