ABC of arrays

Graham Samuel livfoss at mac.com
Wed Apr 1 15:48:02 EDT 2015


Well, Richard, I am always very willing to believe that I’ve misunderstood something, but this is what happened (this material is extracted from conversations I had on this list in the middle of March).

1. I had an XML file - it was actually a .gpx file, which shows a geographical route as a series of waypoints. The ‘top level’ of this structure is ‘gpx’. I mean the first three lines are (watch for wordwrap):

<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" creator="Geolives" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
  <metadata />
  <trk>

2. I converted it to an array using the function ConvertXMLToArray, by Trevor deVore - from Mike Doub’s Master Library.

3. I put the result into an array called ‘gGeneralArray’ - I can see this in the IDE as a nested structure.

4. I executed

  put the keys of gGeneralArray

in the message box, and got the result

 gpx

5. I discussed this on the use-list, and Mike Bonner suggested

> try
> put the keys of gGeneralArray["gpx”]
> and you'll get the next level of keys.

6. I did that and got

wpt[1]
trk
@attributes
wpt[4]
wpt[2]
metadata
wpt[3]

I just did this all again to prove to myself that I hadn’t made an obvious error.I am definitely only dealing with one array, so I can’t explain this, and the LC dictionary certainly doesn’t help.

Tell me where I went wrong!

Graham

> On 1 Apr 2015, at 18:27, Richard Gaskin <ambassador at fourthworld.com> wrote:
> 
> Graham Samuel wrote:
> > And some things are just wrong: for example the very simple statement
> >
> > put the keys of myArray
> >
> > may or may not list all the keys, or it may.  I have never understood
> > this, especially as the Dictionary doesn’t discuss such ambiguities.
> 
> The Dictionary doesn't describe that because it should never happen.
> 
> Under what circumstances would "the keys" not returns the keys?
> 
> FWIW, I've only seen "the keys" return all keys in every version of LC/MC I've ever used.




More information about the use-livecode mailing list