Antwort auf: Arrays in lesbarer Form

Startseite Foren Deutsches LiveCode-Forum Arrays in lesbarer Form Antwort auf: Arrays in lesbarer Form


    Hi Gil,

    ich habe dasselbe Problem gehabt und mir die Funktion umgebaut. Hier ist der Code

    on mouseUp pMouseButton
       put the arraydata of widget "Tree" into tArray
       put displayArrayData(tArray, " ") into tTexttree
       replace "=>  " with empty in tTexttree
       replace "=> Array" with empty in tTexttree
       put tTexttree into field "TextTree"
    end mouseUp
    function displayArrayData pArray, pIndent
       # create the variable that loops through the keys in the array
       local tKey
       if pArray is an array then
          # print information to indicate that we are entering a new nested level of the array
          get "Array" & return
          # print full stops that allow the reader to track the depth of an element
          put " " after pIndent
          # create the indentation
          put tab after pIndent
          repeat for each key tKey in pArray
             # call displayArrayData with a nested array
             put format("%s %s  => %s\n", pIndent, tKey, displayArrayData (pArray[tKey], pIndent)) after it
          end repeat
          delete the last char of it
          return it
          return pArray
       end if
    end displayArrayData