CGrid:Attach


The Attach method attaches an existing grid window and returns it as a new CGrid object. This method works only if the script is run on a grid window with that grid window the top-most window. This is how the script knows which window to attach. If the top-most window is not a grid window when the script attaches it, this function will return nil. To attach the default CGrid pane that opens from the Script Editor, use DefGrid instead. To create a new, empty grid window, use NewGrid.

Syntax

Gtmp = G:Attach()

where

    Gtmp is the CGrid object of the attached grid window. The return value Gtmp equals G if the grid was attached. If not, Gtmp is nil.

  

This method is a class-based version of the global AttachGrid function.

Example

The following script attaches an existing grid window to work with it from the script:

G = G:Attach()

-- Attach an existing grid window

Assert(G, "Not a grid window")

-- exit if nil because not a grid window

c = G:GetCols()

-- Returns the number of grid columns

r = G:GetRows()

-- Returns the number of grid rows

Printf("Grid: %dx%d\n", c, r )

- Result: Grid: 3x50

Related Topics

AttachGrid

NewGrid

new

CGrid class