Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Thoken/Texts
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local debuglog="\n:debuglog:" local valid,duty={},{} local function show(table) local r=" table: " for k,v in pairs(table) do r=r..k..":"..tostring(v).."; " end return r end local function len(table) local r=0 for k,_ in pairs(table) do r=r+1 end return r end local function Scanner(key,buf) -- returns anonymous function to scan a single table entry local pos=0 return function(beg) pos=beg or pos+1 local k=key[pos]; local v=buf[k] if valid[k] then debuglog=debuglog..pos..":"..k..":"..valid[k]..":"..v.." | " end return pos, k, v, valid[k] end end local function class(value) return type(value) -- to be replaced end local function TemplArgs(table) -- initialising tables key, buf - InitArgsClasses to be launched first local key,buf={},{}; local pos=0; local d=len(duty) debuglog=debuglog.." #duty:"..d.." "..show(duty) for k,v in pairs(table) do if not valid[k] then debuglog=debuglog.." <key unknown> "..k.."; " else if valid[k]~=class(v) then debuglog=debuglog.." <key has illegal value> "..k.."; " else pos=pos+1 key[pos]=k; buf[k]=v end if duty[k] and v then d=d-1 end end end if 0<d then debuglog=debuglog.." <mandatory key(s) undefined or missing> "..d.." " end debuglog=debuglog.." - buffered args: "..pos.."\n" return key,buf end local function InitArgsClasses(table) -- initialising tables valid, duty - todo: get argument classes from template page valid={[1]='string', [3]='string', ng='number', ngs='number', nn='number', np='number', nk='number', ne='number', Hauptstadt='string', [5]='string', Insel1='string', Insel2='string', Insel3='string', Insel5='string', Insel6='string', Insel7='string', Journal1='string', Journal2='string', Journal3='number'} duty={[1]=true, Hauptstadt=true, [3]=true, Insel1=true, undefined=true} end local p={} function p.main(frame) InitArgsClasses(frame.args) local key,buf=TemplArgs(frame:getParent().args) local S=Scanner(key,buf) local p,k,v,c=S(); local a="" while c do a=a..p..":"..k..":"..v.."; " -- ...handle... -> wikitext[k] (table of strings) p,k,v,c=S() end return a..debuglog end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Thoken/Texts/doc
(
edit
)