Please enable JavaScript to view this site.

A-Shell Reference

Although you can use a regular for/next loop to effectively iterate through the rows (and for gridmaps with numeric columns, the columns as well), keep in mind that there is no direct way to obtain the extent of any row. And although you can obtain the minimum and maximum row number (using the .minrow and .maxrow dot functions), there is no guarantee that the intervening rows all exist. See Accessing Elements for an example of using the .isnull dot function in connection with a for/next loop to access just the extant values.

Alternately, you can use a foreach $$i loop to iterate through the gridmap as you would through an ordered map, except that it will iterate through the columns of each row before starting on the next row.  Use the .key function to determine the row and column position of the iterator, for example:

foreach $$i in $map()

    ? "Row "; .key($$i,1); ", Col "; .key($$i,2); "-->"; $$i

next $$i

 

Warning: when iterating through numeric rows and columns, although negative values come before positive values in the iteration (as expected), the negative values in the iteration will be ordered according to their absolute value. For example, if the grid contains a range of row numbers from negative two to positive two, they will iterate in the sequence:  -1, -2, 0, 1, 2 (rather than -2, -1, 0, 1, 2). This is a consequence of the way the keys are stored as strings, and also because negative row values are mainly intended to be used for special meta data.

Writeable Iterators

As with ordered map iterators, you can write to the value of a gridmap iterator, but deleting or modifying a key will render the iterator unpredictable.