DUMP_TABLE

Description : Permet de faire un dump d'un tableau. Usage : DUMP_TABLE(t, printFunction, indent, tableHistory) Arguments : - t (?) - printFunction (?) - indent (?) - tableHistory (?) Cette fonction ne retourne aucune valeur. Pour information, voici le code source de cette fonction : -- Outputs the table contents to a function that takes a string as a parameter. -- calls this function once per line. function DUMP_TABLE_TO( t, printFunction, indent, tableHistory ) if ( printFunction == nil) then DEBUG(L" Error in: DUMP_TABLE_TO(table, printFunctions), function for output is nil") return end if (t == nil) then -- Don't ERROR out on this, it stops your script execution...not so desirable for debugging. printFunction (L" Error in: DUMP_TABLE_TO(table), table param is nil") return; end if (type (t) ~= "table") then -- Don't ERROR out on this, it stops your script execution...not so desirable for debugging. printFunction (L" Error in: DUMP_TABLE_TO(table), table param is not a table, type="..towstring(type(t))) return; end tableHistory = tableHistory or {} if (indent == nil or (type (indent) ~= "wstring")) then indent = L""; end for k, v in pairs (t) do local valueType = towstring (type (v)) local keyName = towstring (tostring (k)) local value = towstring (tostring (v)) printFunction (indent..L"("..valueType..L") "..keyName..L" = "..value) if type (v) == "table" then if (tableHistory[v] == nil) then tableHistory[v] = true DUMP_TABLE_TO (v, printFunction, indent..L" ", tableHistory) else printFunction (indent..L"Preventing cycle on table ["..value..L"]") end end end printFunction (indent..L"end") end



Autres termes dans la même catégorie :