This will work with any array. It recursively calls itself as it encounters 
arrays within arrays. I agree with Richard that if all you want is one shot at 
an array to find the element(s) you are looking for, then this may (or may not) 
be a cleaner approach, but I think if you are taking multiple passes at 
finding/filtering with an array, this will at least get you there. If filtering 
with multiple passes, remember to put the text of the array in another variable 
 as filter *replaces* the contents of the source variable with the results. 

Here is the function. Thinking about it, I suppose you could modify this to 
include a filter parameter so that only the keys matching the filter would be 
returned. 

Bob S


function altPrintKeys @pArray, theKeyList
    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

> On Aug 24, 2017, at 12:14 , Sannyasin Brahmanathaswami via use-livecode 
> <use-livecode@lists.runrev.com> wrote:
> 
> what about a 2 diminsional array


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to