Please enable JavaScript to view this site.

A-Shell Development History

 

.MINCOL($grid(),row) - returns first column # in specified row

.MAXCOL($grid(),row) - returns last column # in specified row

.COLNUM($grid(),colname$) - returns column # associated with colname$.

The .MINCOL() and .MAXCOL() functions are only applicable to gridmap(int;int;varstr)—i.e. to gridmaps with numeric row and column indices. But it can handle gridmaps with negative rows and columns and gaps between them (i.e. "sparse" gridmaps).

The .COLNUM() function applies to both gridmap variations, but assumes a "normal form" gridmap—i.e. a gridmap in which row one contains either columns names (gridmap(int;int;varstr) variation) or the first set of data values (gridmap(int;varstr;varstr) variation).

For the gridmap(int;int;varstr) variation, it scans row 1 (whose values are presumed to be the column names) for a value match on the colname$. The returned column number can then be used to directly access values for that column name.

For the gridmap(int;varstr;varstr) variation, .COLNUM() scans row 1 (presumed to be the first data row) for a key match on the colname$, returning the column sequence number—i.e. the ordinal position of the target column in alphabetical sequence, starting from one. In this case the function mainly serves to verify the existence of the target column, perhaps useful after loading a CSV file or SQL query into a gridmap without knowing for sure which column names will be present.

All three functions return -99999999 for error conditions, i.e. if the specified row or colname$ is not found. This is to avoid confusion with the fact that zero could be a valid column number.