e: command setthedata in the data grid api

Sadhu Nadesan sadhu at castandcrew.com
Thu Apr 23 13:17:09 EDT 2009


Trevor wrote:
 > Each time you call DeleteDataOfIndex the index is removed from the 
internal  
 > data grid array and the data grid will be updated visually if the  
 > index is being displayed on screen. Let me know if it works for you.
 >
 > (snip)
 >
 > Regards,
 >
 > -- Trevor DeVore

--------------

Trevor,

Summary

Thank you for the explanation!  I am trying some variations on your 
suggestion.  The code for the repeat loop that will do the deletion is 
not within the behavior script for the data grid, so I cannot use the 
syntax as suggested "of me", right?  The code is part of a menu choice 
so it's in the menu button script.  I am trying to refer to the data 
grid by it's name but do not have the syntax correct. I can't find an 
example.  Details follow.


More Details

Context

Haven't gotten it working yet, perhaps due to misunderstanding of 
syntax, or use of the getdataofindex command,
or where it can be used.  The API manual says

GetDataOfIndex

- GetDataOfIndex (pIndex, pKey)
- Retrieves the internal array for key pIndex of the internal array in 
the data grid. If pKey is empty
then the array associated with key pIndex in the internal data array 
will be returned. If pKey is not
empty then the value of that key for key pIndex of the internal data 
array will be returned.

When I put the following code in the message box, it works

repeat for each item theIndex in the dgIndexes of group "data grid 1" of 
card "data grid card"
  answer theIndex
end repeat


When I add a line to call getdataofindex  (and the grid is not empty in 
column 2, fyi, I think of it as row = index, key = column)

repeat for each item theIndex in the dgIndexes of group "data grid 1" of 
card "data grid card"
answer theIndex
  if GetDataOfIndex(theIndex, "col 2") is not empty then
     answer "not empty"
  end if
end repeat

then the first answer command works, but it never gets to the 2nd one, 
in trying to execute the if statement there is an error message

Message execution error:
Error description: Function: error in function handler

If I change it to refer specifically to the grid, like this

repeat for each item theIndex in the dgIndexes of group "data grid 1" of 
card "data grid card"
  answer theIndex
  if GetDataOfIndex(theIndex, "col 2") of group "data grid 1" of card 
"data grid card" is not empty then
    answer "not empty"
  end if
end repeat

then there is a syntax error

Script compile error:
Error description: if: missing 'then'



Can you enlighten me as to syntax that would work?  Or what I am doing 
wrong?

Thank you again,
Sadhu




More information about the use-livecode mailing list