CGrid:Get
The Get method returns the value in the grid cell at (column, row) or a rectangular region of columns and rows.
array = G:Get()
array = G:Get( CRect )
sValue = G:Get( nCol, nRow )
where
If no arguments are passed, the entire grid is returned as an array of length GetNumCols() * GetNumRows().
CRect is a CRect object specifying the indices for the minimum, maximum columns and minimum, maximum rows to retrieve. The data are returned in an array of length (CRect:Width() + 1) * (CRect:Height() + 1).
nCol, nRow are the column and row indices of the cell to retrieve.
array is a Lua array containing the returned grid data. On failure, nil is returned.
sValue is a string containing the single value returned from the cell at nCol, nRow. On failure, 0 is returned.
The following script creates a grid and stores numbers in columns 1 through 3 and rows 1 through 2. The script retrieves data from all of row 3:
|
-- new grid with 3 cols, 10 rows, 1 Sheet |
|
-- set 5 columns in row 1 |
|
-- set 5 columns in row 2 |
|
-- fetch data from row 3 |
|
-- do for each row |
|
-- result: 2, 3, 4, 4, 5, 6 |
|
|
The following script creates a grid like the one above and retrieves columns 2 and 3 of rows 1 and 2:
|
-- new grid with 3 cols, 10 rows, 1 Sheet |
|
-- set 5 columns in row 1 |
|
-- set 5 columns in row 2 |
|
-- get row 3, starting at column 2 |
|
-- do for each column |
|
-- result: 3, 4, 5, 6 |
|
|
The following script creates a grid like the one above and retrieves the value at columns 2, row 2:
|
-- new grid with 3 cols, 10 rows, 1 Sheet |
|
-- set 5 columns in row 1 |
|
-- set 5 columns in row 2 |
|
-- get row 3, starting at column 2 |
|
-- result: str = 5 |
|
-- result: num = 5 |