יחידה:פרמטרים: הבדלים בין גרסאות בדף
מראה
אין תקציר עריכה |
אין תקציר עריכה |
||
| שורה 17: | שורה 17: | ||
return ans | return ans | ||
end | end | ||
return " | return "<div class=error> '''שגיאת פרמטרים ב[[" .. pframe:getTitle() .. "]]:<br/>" | ||
.. ans .. "'''</div>[[קטגוריה:שגיות פרמטריות]] | .. ans .. "''' </div>[[קטגוריה:שגיות פרמטריות]]" | ||
end | end | ||
גרסה מ־16:38, 7 במאי 2015
function foo(frame)
local ans = ""
local pframe = frame:getParent()
local numbered = 0
local mustnum = tonumber(frame.args[1])
for k, v in pairs( pframe.args ) do
if type( k ) == 'string' then
ans = checknamed(k, ans, frame)
else
numbered = numbered + 1
end
end
if (mustnum < numbered) then
ans = out (ans, "צריך מקסימום " .. mustnum .. " פרמטרים, ישנם " .. numbered)
end
if (ans == "") then
return ans
end
return "<div class=error> '''שגיאת פרמטרים ב[[" .. pframe:getTitle() .. "]]:<br/>"
.. ans .. "''' </div>[[קטגוריה:שגיות פרמטריות]]"
end
function checknamed(k, ans, frame)
local i = 2
while (frame.args[i] ~= nil) do
if (frame.args[i] == k) then
return ans
end
i = i + 1
end
return out(ans, "פרמטר לא ידוע: ''" .. k .. "''")
end
function out(ans, new)
return ans .. new .. "</br>"
end
return {
['main'] = foo
}