When you instruct print to stride across a slice of an array, dbx evaluates certain elements in the slice only, skipping over a fixed number of elements between each one it evaluates.
The third expression in the array slicing syntax, stride-expression, specifies the length of the stride. The value of stride-expression specifies the elements to print. The default stride value is 1, meaning: evaluate all of the elements in the specified slices.
Here is the same array used in the previous example of a slice. This time the print command includes a stride of 2 for the slice in the second dimension.
print arr(201:203, 101:105:2) |
As shown in the diagram, a stride of 2 prints every second element, skipping every other element.
For any expression you omit, print takes a default value equal to the declared size of the array. Here are examples showing how to use the shorthand syntax.
For a one-dimensional array, use the following commands:
Prints the entire array with default boundaries.
Prints the entire array with default boundaries and default stride of 1.
Prints the entire array with a stride of stride-expression.
For a two-dimensional array, the following command prints the entire array.
print arr |
To print every third element in the second dimension of a two-dimensional array, type:
print arr (:,::3) |