You can edit almost every page by Creating an account and confirming your email.

Module:Xswitch/doc

From EverybodyWiki Bios & Wiki

This is the documentation page for Module:Xswitch

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.

This module "Xswitch/doc" is from Wikipedia if otherwise notified