Printkeys() To Array

Bob Sneidar bobs at twft.com
Fri Jan 20 22:20:19 EST 2012


Yes you can. But imagine an array with 10,000 keys. Wouldn't it be nice to be able to delete all the subkeys named "myKey" in that array with just one command? (ok 3 to be honest) Or how about renaming all of a certain key or subkey? I have yet to find a command for that. Those are just two examples of how this could be useful. What if all I cared about in an array were all the keys named "emailaddress" but I wanted to put them into their own array? Once it's all in text form I can use filter on it, but then it's not an array anymore. 

Another way to use it is this: Say you had a numbered array, but the thing you were handing the array off to only cared about the elements at the second level and beyond. You could probably come up with a regex to eliminate all the lines beginning with a number, then convert your string data back to an array again. I ran into that with sqlYoga. Some data types use numbered arrays where others don't. 

Ever tried to combine two arrays? Add one array to the other? How about subtract one array from another? Convert both using printKeys(), do your string magic, then convert it back to an array again. Sure you could write repeat loops to do all that, but this makes it simple and clean. 

The drawback of course is that your array cannot contain anything but values. No graphics, sounds etc. 

I could be over-thinking things again because of too much coffee, but I'm drinking beer now and the idea still seems cool to me. ;-)

Bob

On Jan 20, 2012, at 6:44 PM, Pete wrote:

> Hi Bob,
> I might be misunderstanding your example below but you can delete a key
> from an array along with all its subkeys with "delete theArray[thekey]".
> Is that what you meant?
> 
> On Fri, Jan 20, 2012 at 11:38 AM, Bob Sneidar <bobs at twft.com> wrote:
> 
>> Why you say? Lets say you have an array that you want to delete one key
>> from, say in this case all the secondkey keys. You would have to loop
>> through all the keys deleting each instance of secondkey.
> 
> 
> 
> 
> -- 
> Pete
> Molly's Revenge <http://www.mollysrevenge.com>
> _______________________________________________
> 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