Suppose you’re measuring the performance of a process, keeping track of six different variables, some of which may not used for any given request. In addition to keeping an average, you want to always display the last three measurements. You can use an array with 3 rows and 6 columns, and insert( ) a new row at the beginning of the array for each request. You fill( ) the new row with zeros to initialize the variables in case they’re not used. The code, with simulated input, would look like this:

#define SHOW_LAST 3 // Manifest constants for number of measurements

#define NUM_MEASUREMENTS 6 // to maintain

aMeasure = new Array(SHOW_LAST, NUM_MEASUREMENTS)

aMeasure.fill("") // Start with all blanks

// Simulated input

newRequest()

aMeasure[ 1, 1 ] = 34

aMeasure[ 1, 4 ] = 16

displayArray(aMeasure, 10)

newRequest()

aMeasure[ 1, 3 ] = 67

displayArray(aMeasure, 10)

newRequest()

aMeasure[ 1, 1 ] = 27

aMeasure[ 1, 2 ] = 29

displayArray(aMeasure, 10)

newRequest()

aMeasure[ 1, 2 ] = 31

aMeasure[ 1, 6 ] = 40

displayArray(aMeasure, 10)

// End simulated input

function newRequest()

   aMeasure.insert(1) // Insert row at top, losing last row 

   aMeasure.fill(0, 1, NUM_MEASUREMENTS) // Fill first row with zeros 

The displayArray( ) function is used to display the contents of the array in the results pane of the Command window. It is shown in the example for dimensions.