Cells and tables

Jan Schenkel janschenkel at yahoo.com
Wed Oct 22 06:06:15 EDT 2003


--- Malte Brill <malte.brill at t-online.de> wrote:
> Hi,
> 
> I´ve been experimenting with this a bit and came up
> with the following:
> 
> [snip]
> 
> Then you can refer to each cell like this:
> 
> put the cell_3.1 of fld "myField"
> 
> I like this. :-)
> 
> Regards,
> 
> Malte
> 

Hi Malte,

Excellent work ; allow me to add a few ideas, though :
- it might be easier to store the cells into a
customPropertySet, so that you can address them in
array notation.
- adding a setProp and getProp for this set would also
allow you to update individual data

No for a few additions to your field script :-)

local sGeneratingCells

on rawkeyDown
  send generateCells to me in 10 ticks
  pass rawkeyDown
end rawkeyDown

on generateCells
  -- clear the previous content
  set the customProperties["cell"] to empty
  -- now fill the individual custom props
  set the itemdel to tab
  put true into sGeneratingCells
  put 0 into lLineCounter
  repeat for each line row in me
    add 1 to lLineCounter
    put 0 into lItemCounter
    repeat for each item colum in row
      add 1 to lItemCounter
      set the uCell[lLineCounter,lItemCounter] \
          of me to item lItemCounter of row
    end repeat
  end repeat
  put false into sGeneratingCells
end generateCells

setProp uCell[pCoordinates] pNewContent
  if sGeneratingCells is not "true" then
    put item 1 of pCoordinates into tRow
    put item 2 of pCoordinates into tColumn
    put pNewContent into item tColumn \
        of line tRow of me
  end if
  pass uCell
end uCell

--

The local sGeneratingCells allows setProp to make a
distinction between having to update the data in the
field or not.

There you go, a convenient way to get and set the data
of individual cells, linked to the text of the field.

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com


More information about the Use-livecode mailing list