Print R
From Director Online Wiki
on print_R(plist, tabs) -- Takes a propList and returns its string equivalent -- in human readable (but still "value()able") form :). -- Based on php's print_r function. EOLN = " \" &RETURN lCount = plist.count str = "[" &EOLN repeat with i = 1 to lCount p = getPropAt(plist, i) v = getAt(plist, i) -- If we recurse, then the following should cause our -- nested proplist to be indented. thisLine = "" repeat with j = 1 to tabs put TAB after thisLine end repeat case (p.ilk) of (#integer): put string(p) after thisLine (#string): put QUOTE&p"E after thisLine (#symbol): put "#"&string(p) after thisLine otherwise put "Unsupported property type: " &p end case put ": " after thisLine case (v.ilk) of (#string): put QUOTE&v"E after thisLine (#symbol): put "#"&string(v) after thisLine (#void): put "#void" after thisLine (#proplist): put print_R(v, tabs+1) after thisLine otherwise put string(v) after thisLine end case if (i < lCount) then put "," after thisLine put EOLN after thisLine put thisLine after str end repeat eof_plist = "" repeat with j = 1 to tabs put TAB after eof_plist end repeat put eof_plist &"]" after str return str end
--[[User:Cole|CBT]] 13:14, 12 Oct 2005 (MDT)