find (and table fields)

Jan Schenkel janschenkel at yahoo.com
Sun Feb 1 03:12:01 EST 2004


--- David Squance <squance at elkvalley.net> wrote:
> And while our gurus are thinking about table fields,
> coincidentally, I've
> been trying to find the syntax for getting the
> contents of a cell in a
> table field.  The glossary says a cell is specified
> by its column and row
> numbers (eg: 1,2), but playing with a table and the
> message box, I
> can't 'put' the contents of cell.  Is there simple
> syntax for this?
> Dave
> 

Hi Dave,

As the text is stored in a tab-delimited manner, you
can get at an individual cell quite easily :
--
  set the itemDelimiter to tab
  get item 3 of line 4 of field "Foobar"
--

During a discussion on this list a while ago, the
following script ws developed to allow the easy
setting and getting of individual calls in a table, by
mean of custom properties :
--
getProp uCell[pIndex]
  # this allows you to get the content of a cell

  # extract the row and column from the index param
  put item 1 of pIndex into tRow
  put item 2 of pIndex into tCol
  # now return the data in that cell
  set the itemDelimiter to tab
  return item tCol of line tRow of me
end uCell

setProp uCell[pIndex] pContent
  # this allows you to set the content of a cell

  # extract the row and column from the index param
  put item 1 of pIndex into tRow
  put item 2 of pIndex into tCol
  # now return the data in that cell
  set the itemDelimiter to tab
  put pContent into item tCol of line tRow of me
end uCell
--

If you put the above into the script of the field, you
can get and set the content of individual cells by
calls like :
--
  get the uCell[9,2] of field "Foobar"
  set the uCell[3,4] of field "Foobar" to "Snafu"
--

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!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/


More information about the use-livecode mailing list