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

29
LINES

< > BotCompany Repo | #536 // Return reference tree (without bridge stuff & invalidated)

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)
    if not (title:find("^Need bridge ") or title:find("^A bridge ") or title:find("^A master bridge ") or hasNTTitle("Invalidate "..id)) then
      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
end

result = {}
table.insert(result, "Shortened reference tree for "..startID.." (without bridge stuff & invalidated):\n")
printReferenceTree(startID, "", {}, result)
result = table.concat(result, "\n")
print("\n"..result)
return result

Author comment

Began life as a copy of #528

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: #536
Snippet name: Return reference tree (without bridge stuff & invalidated)
Eternal ID of this version: #536/1
Text MD5: a119aa86b492b6f3d07846747225bf81
Author: stefan
Category:
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-03-15 17:23:45
Source code size: 967 bytes / 29 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 761 / 177
Referenced in: [show references]