Missing keys in datagrid?

Bob Sneidar bobsneidar at iotecdigital.com
Tue Dec 17 19:13:47 EST 2019


If I recall a long time ago speaking with Trevor, printkeys() does not necessarily return ALL keys. Your array does not look that large though. 

I have an array function that may prove more helpful. I designed it so that you could "search" or filter an array for a key and/or a value. It will return text looking something like:

[1] ["lastupdate"] 	2016-09-07 13:56:01,[1] ["contactcell"] 	,[1] ["siteidlist"] 	,[1] ["contactid"] 	409,[1] ["contactname"] 	Stonehill Technical Solutions,[1] ["contactphone"] 	949-218-1258,[1] ["updateby"] 	Robert Sneidar,[1] ["itidlist"] 	|396|,[1] ["custid"] 	340,[1] ["contactemail"] 	,[1] ["contacttype"] 	|customer|site|it|,[1] ["position"] 	
[2] ["lastupdate"] 	2016-09-07 13:56:01,[2] ["contactcell"] 	,[2] ["siteidlist"] 	|397|,[2] ["contactid"] 	410,[2] ["contactname"] 	Jackie Silventez,[2] ["contactphone"] 	951-943-2223,[2] ["updateby"] 	Robert Sneidar,[2] ["itidlist"] 	,[2] ["custid"] 	340,[2] ["contactemail"] 	,[2] ["contacttype"] 	|site|,[2] ["position"] 	

etc.

It has the format [first root key] [first child key] [next child key] [next child key] (etc.)<vert tab>"key value",[first root key] [second child key]...

and so on. The value to this format is you can use the filter lines command to, for example find every line containing *["custid"]<vert tab>340*. Each line will then contain the actual array keys for that entry, which you can use to reference the original array. In this case the root key is 1, the first child key is "custid" the value is 340. 

It seems complicated at first but it's not. Try it with a 3 deep multi key array. It gives you the ability using the filter lines command to find every matching array key with a single statement. 

Bob S


function altPrintKeys @pArray
   put numtochar(11) into vertTab
   put numtochar(30) into altCr
   put the keys of pArray into theKeys
   sort theKeys numeric
   
   repeat FOR each line theKey in theKeys
      put "[" & theKey & "] " after theKeyList
      if theKey is not a number then
         replace "[" & theKey & "]" WITH "[" & quote & theKey & quote & "]" in theKeyList
      end if
      if pArray[theKey] is an array then
         put pArray[theKey] into theTempArray
         put altPrintKeys(theTempArray, theKeyList, pFullData) after theText
         put empty into the last word of theKeyList
         delete the last char of theKeyList
         put cr into the last char of theText
      else
         put "pArray " & the last word of theKeyList into theKeyName
         -- put "put " & theKeyName & " into theValue" into theCommand
         -- do theCommand
         put value(theKeyName) into theValue
         replace tab WITH vertTab in theValue
         replace return WITH altCr in theValue
         put theKeyList & tab & theValue & comma after theText
         put empty into the last word of theKeyList
         delete the last char of theKeyList
      end if
   end repeat
   
   return theText
end altPrintKeys

Bob S


> On Dec 17, 2019, at 12:13 , Klaus major-k via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Hi friends,
> 
> I have a datagrid "produkte" of type Table with these 12 columns:
> 1. lfd_nummer
> 2.Titel
> 3.sid
> 4.währung
> 5.Kupon
> 6.barriere
> 7. Verfallsdatum
> 8.Basiswerte
> 9. status
> 10. statusstatus
> 11. abruffehler
> 12. abruffehlermeldung
> 
> But when I fire this in the messagebox: 
> send "printkeys" to grp "produkte", I only get 10 keys? 
> 1
> Verfallsdatum: ``
> abruffehlermeldung: ``
> lfd_nummer: `0018`
> status: ``
> sid: `44`
> Titel: `sdsdsdds`
> Basiswerte: `Aktien`
> Kupon: `50.00%`
> barriere: `80.00%`
> währung: `CHF`
> 
> Same with: 
> put the dgdata of grp "produkte" into tt;put keys of tt[1]
> Verfallsdatum
> abruffehlermeldung
> lfd_nummer
> status
> sid
> Titel
> Basiswerte
> Kupon
> barriere
> währung
> 
> Again only 10 keys from total 12!? What am I missing?
> Tested on macOS 10.14.6 with LC 9.05, 9.04 and 9.5.1 GM.
> 
> 
> Best
> 
> Klaus
> --
> Klaus Major
> https://www.major-k.de
> klaus at major-k.de
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list