Missing keys in datagrid?

Trevor DeVore lists at mangomultimedia.com
Wed Dec 18 07:28:46 EST 2019

On Wed, Dec 18, 2019 at 2:38 AM Klaus major-k via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Hi Bob,
> > Am 18.12.2019 um 01:13 schrieb Bob Sneidar via use-livecode <
> use-livecode at lists.runrev.com>:
> >
> > If I recall a long time ago speaking with Trevor, printkeys() does not
> necessarily return ALL keys.
> AHA!
> OK, that explains something, but not all.
> Empty or not, this SHOULD list all keys, but doesn't?

One nice aspect of LiveCode is that you can inspect all of the code to see
what is going on behind the scenes. For PrintKeys you can get to the script
that has it in one of two ways:

edit script of behavior of behavior of selobj()
edit script of stack "RevDataGridLibraryBehaviorsDataGridButtonBehavior"

This is the PrintKeys handler:

command PrintKeys pArray
    if pArray is not an array then put sDataArray into pArray
    put _PrintKeys(pArray)
end PrintKeys

And here is the _PrintKeys() function:

private function _PrintKeys @pArray, pDimension
   if pDimension is empty then put 0 into pDimension

   local theKeys, theText, theTempArray
   put the keys of pArray into theKeys
   sort theKeys numeric

   repeat for each line theKey in theKeys
      if pArray[theKey] is an array then
         put _printCharXTimes(space, pDimension * 5) & theKey & cr after
         put pArray[theKey] into theTempArray
         put _PrintKeys(theTempArray, pDimension + 1) after theText
         put _printCharXTimes(space, pDimension * 5) &  theKey & ":" && "`"
& pArray[theKey] & "`" & cr after theText
      end if
   end repeat

   return theText
end _PrintKeys

As you can see, PrintKeys prints off every key and value in the sDataArray
array. sDataArray contains the array that you, the developer, assigned to
the DataGrid using a property such as dgData or dgText. PrintKeys doesn't
take into account the columns you've created in your DataGrid. That is a
separate property.

So my guess is that you are populating the DataGrid with data that only has
10 columns. Could that be the case?

Trevor DeVore

More information about the use-livecode mailing list