table cell contents

Jan Schenkel janschenkel at yahoo.com
Tue Sep 21 08:47:37 EDT 2004


--- Alister Pillow <alisterhp at mac.com> wrote:
> Hi
> I've been looking everywhere (docs, lists etc) for
> an example of how to 
> set the contents of a table field which has "cell
> editing" turned on.
> 
> If I put some text into the "Contents" panel of the
> (table field) 
> Property Inspector, the text appears correctly in
> the table - until the 
> table is clicked in browse-mode, when the text
> disappears.
> 
>  From the message box...
> 	set the text of field "mytable" to "fish" &  tab &
> "potato"
> ... works as expected, setting cells 1 and 2 of row
> 1 - but as soon as 
> I click in the table, that text disappears.
> 
> In the same table, I can click in a cell, type some
> text "cheese", tab 
> to the next cell and add more text "lettuce" - all
> works as expected. 
> Then, if I run the above script from the message
> box, the content is 
> replaced (as expected). But when I click the field,
> "fish" and "potato" 
> are immediately replaced by "cheese" and "lettuce".
> 
> Is this a bug or am I missing something? Are there
> any docs on using 
> the "table field"?
> 
> Thanks,
> Alister.
> 

Hi Alister,

You are right, the "table field" mechanism is at this
point undocumented. However, since I recently did some
maintenance on it, I can answer your question :

1) use the function "revReadCellValue" to get the text
or htmlText of a particular cell ; its signature :
  function revReadCellValue(<field reference>,
<column>, <row>, <format>)

As an example :
--
  put the long id of field "MyTable" into tLongID
  put 5 into tRow
  put 8 into tColumn
  put "text" into tFormat
  put revReadCellValue(tLongID,tColumn,tRow,tFormat) \
      into tCellValue
--

2) use the command "revWriteCellValue" to change the
value of a particular cell ; its signature :
  command revWriteCellValue <field reference>,
<column>, <row>, <value>

As an example :
--
  put the long id of field "MyTable" into tLongID
  put 5 into tRow
  put 8 into tColumn
  put "sometext" into tValue
  revWriteCellValue tLongID,tColumn,tRow,tValue
--

3) A note of warning to those who are thinking of
using the above with database-linked table fields :
revWriteCellValue will not update the database by
itself ; you'll have to use another undocumented call
"revUpdateDatabase" for that ; its signature :
  command revUpdateDatabase <field reference>,
<column>, <row>, <text value>

Adapting the above example :
--
  put the long id of field "MyTable" into tLongID
  put 5 into tRow
  put 8 into tColumn
  put "sometext" into tValue
  revWriteCellValue tLongID,tColumn,tRow,tValue
  revUpdateDatabase tLongID,tColumn,tRow,tValue
--

The only problem is that in view of all the requests
for more and better table functionality, these
commands and functions may not be around  in the
future -- though I'm guessing these would get mapped
onto their future variants if the need arises.

Hope this helped,

Jan Schenkel ~ jan at runrev.com ~ http://www.runrev.com
Runtime Revolution - User-centric Development Tools


		
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail 


More information about the use-livecode mailing list