Modulo:mchkparametrojn: Malsamoj inter versioj
Enhavo forigita Enhavo aldonita
d |
plibo |
||
Linio 3:
MODULE "mchkparametrojn" (check parametrojn)
"eo.wiktionary.org/wiki/Modulo:mchkparametrojn" <!--2019-Jun-
"id.wiktionary.org/wiki/Modul:mchkparametrojn"
Purpose: performs 2 comparisons in order to check validity
of the anonymous parameters submitted the caller, even empty
parameters can
"E" option, otherwise they are considered as an error, can check
availability of obligatory named parameters too
Utilo: efektivigas 2 komparojn por kontroli validecon
de la anonimaj parametroj transdonitaj al la vokanto, ecx malplenaj
parametroj povas esti
"E" opcio, alimaniere ili estas pritraktataj kiel eraro, povas ankaux
kontroli disponeblon de devigaj nomitaj parametroj
Manfaat:
parameter anonim dikirim kepada pemanggil, bahkan parameter
kosong bisa ... dan dihitung dengan opsi "E" ... parameter bernama
Used by templates / Uzata far sxablonoj:
Linio 54 ⟶ 56:
<!--enkonduko#
#protekto-->{{#if:<!--o-->{{{1|}}}<!--o-->|<!--then-->{{#inv
oke:mwhineplendu|ek}}
#kerno-->"Hello world!" from template "contoh"<!--kerno#
#protekto-->}}<!--endif--><!--protekto#
Linio 83 ⟶ 85:
"{{#invoke:mchkparametrojn|ek|0|0|nama|umur}}"
"<!--enkonduko#
#protekto-->{{#ifeq:<!--o-->{{#invoke:mchkparamet
rojn|ek|1|2}}<!--o-->|<!--equal-->0<!--o-->|<!--then-->{{#invoke:mwhin
eplendu|ek}}<!--o-->}}<!--endif-->{{#ifeq:<!--o-->{{#invoke:mchkparamet
rojn|ek|1|2}}<!--o-->|<!--equal-->1<!--o-->|<!--then--><!--protekto#
#kerno-->"Hello world!" from template "contoh"<!--kerno#
#protekto-->}}<!--endif--><!--protekto#
#fino-->"
Notes about the examples of "protekto":
- In all 3 examples the "kerno" part is in the else-branch of an
if-structure. This means that the "kerno" part may NOT contain
unprotected walls "|", most notably "wikitables".
- The latter example invokes "mchkparametrojn" 2 times due to the risk
of "module failed to run". Make sure that both calls are identical.
]===]
Linio 254 ⟶ 272:
if (vartmp==nil) then
booerr = true
break -- expected named parameter NOT found, this is fatal
else
if ((booemp==false) and (vartmp=="")) then
booerr = true
break -- empty parameter found without "E", this is fatal too
end--if
end--if
Linio 272 ⟶ 290:
---- RETURN THE JUNK STRING ----
return strret -- can be
end--function
|