This is the documentation page for Module:Xswitch
| This module is rated as pre-alpha. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure. |
This module is a pretty haphazard implementation of a discussed Lua request. (yes, you can do better than this) It takes an input number or string (the first numbered parameter) and sorts it back through the thresholds it is given until it finds one that it is greater than - then it spits out that result. The thresholds and results are given either as parameters or as a file. For example:
{{#invoke:xswitch|main
|profile={{some file}}
|type=string
|ant
|astronaut|astronaut
|Cherry|Cherry
|Apple|Apple
|cosmonaut|cosmonaut
|camper|camper
}}
will take the profile from "some file" that you've transcluded, ignoring everything after "ant". But if the profile were omitted, it would return "Apple" because that is the first thing working backwards that it is greater than. If you want smarter behavior than that, sort your parameters. :)
The file to accomplish the same tests would read
|astronaut|astronaut |Cherry|Cherry |Apple|Apple |cosmonaut|cosmonaut |camper|camper
The idea is/was that for a very long set of tests you might want to put them all in a file to edit, so you don't have to pass them all in the template each time and can edit them in one place.
Setting type to anything forces a string comparison - otherwise a numeric comparison is forced.
