try " put the keys of gGeneralArray["gpx"] and you'll get the next level of keys.
On Sun, Mar 15, 2015 at 1:27 PM, Graham Samuel <[email protected]> wrote: > Thanks Peter, it seems to work very well. I tried it on my XML-derived > test file, which I put (as an array) into a global, gGeneralArray. > > Hoping you’ll excuse the bandwidth, I’ll show you the first few lines of > text from your function's output, as I would like to ask a question about > it: > > gpx > @attributes > creator: Geolives > schemaLocation: http://www.topografix.com/GPX/1/1 > http://www.topografix.com/GPX/1/1/gpx.xsd > version: 1.1 > xmlns: http://www.topografix.com/GPX/1/1 > metadata: > trk > trkseg > trkpt[1000] > @attributes > lat: 43.099438 > lon: 2.075522 > ele: 392.6022 > time: 2015-03-12T10:34:43Z > trkpt[1001] > @attributes > lat: 43.099384 > lon: 2.0755 > ele: 392.6022 > time: 2015-03-12T10:34:47Z > trkpt[1002] > @attributes > lat: 43.099335 > lon: 2.075483 > ele: 393.96625 > time: 2015-03-12T10:34:51Z > > This seems to me to show a multidimensional array, but perhaps it doesn’t, > because when I do this in the Message Box > > put the keys of gGeneralArray > > I just get > > gpx > > But I can see all the other keys (can’t I?) in above display and in the > IDE - they derive from different levels of angle brackets in the XML. > Perhaps I’m simply going crazy. > > Just going back to my model of LC arrays - can someone tell me if this is > reasonable: > > An array is a kind of group, or a physical analogy would be a box. This > group (box) contains elements which can be actual objects (numbers for > example) or other groups (boxes). This nesting can go on as deep as you > like. So a reference like > > myArray[“aa”][“bb”] > > means ‘get me out the box or object labelled “bb” from the box labelled > “aa”. We only find out if it’s a box (i.e. another array) or a real object > when we go to fetch it. > > I’m using this model to get as far away as possible from the numerically > indexed arrays I was brought up with. Is it wrong? > > TIA > > Graham > > On 15 Mar 2015, at 19:32, Peter M. Brigham <[email protected]> wrote: > > > > Not a utility, but here's a way of displaying a multilevel array so you > can see its structure. > > > > -- Peter > > > > Peter M. Brigham > > [email protected] > > http://home.comcast.net/~pmbrig > > > > ------- > > > > function displayArray @pArray, pFullData, _pDimension > > -- by Peter M. Brigham, [email protected] — freeware > > -- adapted from a handler by Trevor DeVore > > -- displays an array as an outline-style list > > -- most useful for multidimensional arrays, to see the structure > > -- if an element of the array contains more than one line, > > -- the first line only will be displayed (less confusing to look at) > > -- if you want to see the full data then pass pFullData = true > > -- _pDimension is an internally used parameter > > -- pArray is referenced to avoid duplicating large arrays in memory, > > -- but the array is not altered by this function > > > > -- call it like this: put displayArray(tArray) into fld "peruse" > > > > -- requires makestring() > > > > if _pDimension is empty then put 0 into _pDimension > > if pFullData = empty then put false into pFullData > > put ": " into divString > > put the keys of pArray into theKeys > > if line 1 of theKeys is a number then > > sort theKeys numeric > > else > > sort theKeys > > end if > > repeat for each line theKey in theKeys > > if pArray[theKey] is an array then > > put makeString(space,_pDimension*3) & theKey & cr after theText > > put pArray[theKey] into theTempArray > > put displayArray(theTempArray, pFullData, _pDimension + 1) after > theText > > else > > if pFullData then > > put makeString(space,_pDimension*3) & theKey & ":" \ > > && pArray[theKey] & cr after theText > > else > > put pArray[theKey] into tElement > > put empty into tTrailer > > if the number of lines of tElement > 1 then > > put " ..." into tTrailer > > end if > > put makeString(space,_pDimension*3) & theKey & divString \ > > & (line 1 of tElement) & tTrailer & cr after theText > > end if > > end if > > end repeat > > return theText > > end displayArray > > > > function makeString pChar, n > > -- returns a string of n characters (pChar) > > -- no repeat loop! > > -- by Peter M. Brigham, [email protected] — freeware > > -- improved by Richard Gaskin > > set the linedel to pChar > > put pChar into line n of temp > > return temp > > end makeString > > > > > > On Mar 15, 2015, at 2:19 PM, Mike Bonner wrote: > > > >> If you are just trying to get a handle on the structure, and how to pull > >> out specific chunks, you can declare it global, and use the message box > to > >> poke around. > >> > >> If its global, in the multiline msg box declare it too, and "put the > keys > >> of... " > >> Then adjust it to look at subkey contents, poking around till you figure > >> out where things are. > >> > >> And now i'm wondering if anyone has built an array browser utility? > >> > >> On Sun, Mar 15, 2015 at 11:56 AM, Scott Rossi <[email protected]> > >> wrote: > >> > >>> Try: if myArray is an array > >>> > >>> > >>> Regards, > >>> > >>> Scott Rossi > >>> Creative Director > >>> Tactile Media, UX/UI Design > >>> > >>> > >>> > >>> > >>> On 3/15/15, 9:50 AM, "Graham Samuel" <[email protected]> wrote: > >>> > >>>> Still struggling with arrays: no results, no error messages, no dataŠ > >>>> will get there no doubt. While trying to get there, I tried > >>>> > >>>> put exists(myArray[³gpx²]) > >>>> > >>>> I got Œfalse¹, but the IDE seems to say that the top key in this > >>>> multidimensional array is ³gpx², so why isn¹t it true? > >>>> > >>>> Puzzled on a wet Sunday afternoonŠ > >>>> > >>>> Graham > >>>> > >>>> > >>>> > >>>> _______________________________________________ > >>>> use-livecode mailing list > >>>> [email protected] > >>>> Please visit this url to subscribe, unsubscribe and manage your > >>>> subscription preferences: > >>>> http://lists.runrev.com/mailman/listinfo/use-livecode > >>> > >>> > >>> > >>> _______________________________________________ > >>> use-livecode mailing list > >>> [email protected] > >>> Please visit this url to subscribe, unsubscribe and manage your > >>> subscription preferences: > >>> http://lists.runrev.com/mailman/listinfo/use-livecode > >>> > >> _______________________________________________ > >> use-livecode mailing list > >> [email protected] > >> Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > >> http://lists.runrev.com/mailman/listinfo/use-livecode > > > > > > _______________________________________________ > > use-livecode mailing list > > [email protected] > > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > > http://lists.runrev.com/mailman/listinfo/use-livecode > > _______________________________________________ > use-livecode mailing list > [email protected] > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > _______________________________________________ use-livecode mailing list [email protected] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
