﻿# Special Gridmap Functions

_Updated August 2023; see History_

| **Function** | **Type** | **Description** |
|------|------|------|
| .EXTENT(\$a()) | [Num](num.md) | Returns the total # of values, i.e. (row,col,value) triplets, in the gridmap \$a(). Returns -1 if the gridmap has not yet been initialized or was subsequently destroyed with [REDIMX](redimx.md). |
| .ISNULL(var)  | [Boolean](datatypes.md#booleandatatype) | Tests the expression expr for null (same as for ordered maps). Expression may be an iterator, e.g. .ISNULL(\$\$i), or a gridmap element reference, e.g. .ISNULL(\$a(row,col)), or a string variable. |
| .KEY(\$\$i, 1) | [String](string.md) | Returns the row key (key #1), associated with the element currently indexed by the iterator \$\$i. See Comments below. |
| .KEY(\$\$i, 2) | [String](string.md) | Returns the column key (key #2), associated with the element currently indexed by the iterator \$\$i. See Comments below. |
| .MINROW(\$a()) | [Num](num.md) | Returns the first row number. |
| .MAXROW(\$a()) | [Num](num.md) | Returns the last row number. |
| .MINCOL(\$a(),row) | [Num](num.md) | Returns the first (lowest) column number on the specified row (or -99999999 if none). Applies only to gridmaps with numeric column indices, i.e. gridmap(int;int;varstr).  |
| .MAXCOL(\$a(),row) | [Num](num.md) | Same as .MINCOL(\$a(),row) except for the last (highest) column number on the row. |
| .COLNUM(\$a(),colname\$) | [Num](num.md) | Returns the column number associated with colname\$ (or -99999999 if no match). Applies to both gridmap variations. For gridmaps with numeric column indices, it scans row 1 to find a value match on the colname\$; the resulting column number can be used (along with a row number) to directly address the gridmap. For gridmaps with string column indices, it scans row 1 (presumed to be the first data row) for a key match on the colname\$, returning the ordinal sequence # (starting from 1) of the matching column. That mainly serves just to verify the existence of the target column. |




**Comments**

Note that the .KEY() functions are of type string; use the [VAL()](val()andval$().md) function to convert the result to a numeric value suitable for comparing to row and column numbers. Otherwise you may be tripped up by the fact that "2" > 10.

**See Also**

•	[INPCSVX.BP in the EXLIB](https://bitbucket.org/microsabio/exlib/src/master/908092/inpcsvx.bp) for an example involving some of these gridmap functions.

**History**

2023 July, A-Shell 6.5.1736:  .MINCOL(), .MAXCOL() and .COLNUM() added.

2023 July, A-Shell 6.5.1734:  .MINROW() extended to work for negative row numbers.