Module talk:Iteration/doc
Jump to navigation
Jump to search
Description of the Lua local function "samefile"
[edit]It needs five parameters, of which the first three are passed by the invokation
It provides special treatment when str(1) is empty, starts with a dot, or is a dot
- string: a file name, or an extension, or empty
- integer: current number >= 1
- string: a file name, or an extension, or empty
- integer: nsnumber, mw.title.getCurrentTitle().namespace
- string: pagename, mw.title.getCurrentTitle().text e.g. a file name when invoked from the FILE namespace
- When the str(1) is neither empty, nor starts with a ".",
- then str(1) will be returned.
- Otherwise, when str(1) is empty,
- when int(2) = 1
- and int(4) is 6 or 7
- then str(5) will be returned
- otherwise "Example.svg" will be returned;
- and int(4) is 6 or 7
- when int(2) = 1
- when int(2) ≠ 1
- and str(3) is neither empty, nor starts with a ".",
- then str(3) will be returned;
- otherwise str(3) is ignored and the same processing occurs as above for int(2) = 1.
- and str(3) is neither empty, nor starts with a ".",
- when int(2) ≠ 1
- Otherwise, when str(1) starts with a ".",
- and int(4) is 6 or 7
- then str(5) is assumed to be a valid filename
- and str(5) with the extension changed by str(1) will be returned.
- When int(4) is neither 6 nor 7
- a filename "Example" with the extension str(1) will be returned.
- and int(4) is 6 or 7
Str(1) starting with a "." can be either a valid extension, or an abbreviation where
- ".p" stands for ".png" (can also be abbreviated with only a ".")
- ".j" stands for ".jpg"
- ".g" stands for ".gif"
- ".s" stands for ".svg"