Further dumb question about arrays

Graham Samuel livfoss at mac.com
Sat Mar 14 09:21:15 EDT 2015


Thanks to help from this list, I’ve used Trevor’s ‘ConvertXMLtoArray’ to convert an XML file into a multidimensional array. Looks good in the IDE, but I can’t understand how to access its elements by following the scraps of advice in the User Guide. The IDE says that my array (say ‘myArray’) looks like this

gpx
  @attributes
  metadata
trk
  trkseg
    trkpt[1001]
      @attributes
            lat*
            lon*
         ele*
         time*
    trkpt[1002]

   etc (there are thousands of elements at the ’trkpt’ level)

The lines marked with an asterisk have actual values, for example the ‘time’ element contains a time.

I have tried to follow the documentation, but I can’t understand how to address a specific element, much less loop through the whole array. For instance, how would I get the time for trkpt[1001]? It must be obvious to many, but not to me. The general syntax seems to be of the form

 put myArray[key1][key2]…[keyn] into someVariable

where the keys are strings in quotes (or presumably expressions that evaluate to strings), but I haven’t hit on any sequence that just shows me one element, like the time.

I feel stupid, but I have tried.

Thanks for any clarification.

Graham



More information about the use-livecode mailing list