Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

27
LINES

< > BotCompany Repo | #528 // Return reference tree (generic)

Lua code

get("#175") -- tableToString
get("#349") -- table functions

startID = input or error("Need snippet ID as input")

function printReferenceTree(id, indent, seen, result)
  if seen[id] then
    table.insert(result, indent..id.." (see above)")
  else
    title = getSnippetTitle(id)
    table.insert(result, indent..id.. " - "..title)
    seen[id] = true
    
    local refs = getTitleReferences(id)
    --print("Refs: "..tableToString(refs))
    for r in all(refs) do
      printReferenceTree(r, indent.."  ", seen, result)
    end
  end
end

result = {}
table.insert(result, "Full reference tree for "..startID..":\n")
printReferenceTree(startID, "", {}, result)
result = table.concat(result, "\n")
print("\n"..result)
return result

Author comment

Began life as a copy of #526

test run  test run with input  download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #528
Snippet name: Return reference tree (generic)
Eternal ID of this version: #528/1
Text MD5: bde4ea56add89877f212e708cfc92a15
Author: stefan
Category:
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-03-20 20:09:56
Source code size: 757 bytes / 27 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 819 / 205
Referenced in: [show references]