Volatile:ListField: Difference between revisions

(New page: <!----List fields of name "<nowiki>{{{1|}}}</nowiki>" in namespace "<nowiki>{{{2}}}</nowiki>".---->{{#lua: function trim(s) return (string.gsub(s, "^%s*(.-)%s*$", "%1")) end list = {} ...)
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<!----List fields of name "<nowiki>{{{1|}}}</nowiki>" in namespace "<nowiki>{{{2}}}</nowiki>".---->{{#lua:
<!----List fields of name "<nowiki>{{#get:1}}</nowiki>" in namespace "<nowiki>{{#get:2}}</nowiki>"---->
  function trim(s) return (string.gsub(s, "^%s*(.-)%s*$", "%1")) end
{{#def:ARG1|{{#get:1}}}}{{#def:ARG2|{{#get:2}}}}{{#def:ARG3|{{#get:3|0}}}}
  list = {}
==Search Results of '''{{#get:1}}'''==
  id = {}
{{#invoke:ListField|func1|{{#replace:{{#SearchLine:{{#var:ARG1}}|{{#var:ARG2}}}}|&#124;|&&}}|{{#get:1}}|{{#var:ARG2}}|{{#var:ARG3}}}}
  for page,data in stdin:gmatch("&&([%S]+)&&{{{1}}}= *([^\n]+)") do
    if ((data ~= "-") and (data ~= " ")) then
      data = trim(data)
      tmp = list[data]
      if (tmp == nil) then
        list[data] = { page }
        table.insert(id, data)
      else
        table.insert(tmp, page)
      end
    end
  end
  table.sort(id)
  for _,v in ipairs(id) do
    print("* {{{1}}} '''" .. v .. "'''")
    table.sort(list[v])
    local f = true
    for i = 1,table.getn(list[v]) do
      if list[v][i] ~= list[v][i + 1] then
        print("[[{{{2}}}:" .. list[v][i] .."|".. list[v][i] .."]]") end
    end
  end
|
{{#replace:{{#SearchLine:{{{1}}}|{{{2}}}}}|&#124;|&&}}
}}

Latest revision as of 07:28, 30 January 2023


Search Results of

Lua error in Module:ListField at line 16: attempt to concatenate local 'arg1' (a nil value).