Template:Random/doc: Difference between revisions
m (Bot: Adding <noinclude>{{PAGENAME}}</noinclude>) |
m (Protected "Template:Random/doc": Robot: Protecting all pages from category templates ([edit=sysop] (indefinite) [move=sysop] (indefinite))) |
(No difference)
|
Revision as of 02:08, 13 May 2013
{{random}} generates a random number, at least to the extent that non-mathematicians will be happy with the term "random", through simple markup. The number can be from 1 to whatever number you choose, up to 1000.
Syntax is straightforward:
{{random|1000}} = 219
This number will change every time the page loads.
Though this simple aspect is enough to power any number of functions — such as determining which random, numbered subpage to call on a page, the template does have additional sophistication, detailed at template:random on Wikipedia.
Example of calling forth a page
If you type the following, you will get a different quote of the week on every page load:
{{qotw/{{#expr:{{random|52}} + 1}}}}
Test it out by reloading this page several times. What you get below will be different on almost every page, though with a sample size of only 52, you're bound to get some repeats. The reason is because there are 53 pages in the following format:
{{qotw/n}}
However, there is no {{qotw/0}}. Thus by adding 1 to the randomly selected number between 0 and 52, we ensure the choice will be between the numbers 1 and 53.
- Rose: There are people inside that?
- Tenth Doctor: Heroes inside that. The first humans to travel through hyperspace, thy're out further than any human's been before. Apart from you, obviously. That's the planet Phostris, in the galaxy RE 461. They volunteered, risked their lives to get here. Brave pople. Spreading humanity's innovations through the universe.
- Rose: One more question. Hyperspace . . . ?
- Tenth Doctor: Space is a B road, hyperspace is a motorway. Gets you where you want to go very, very fast. But you have to punch a hole in space to get on it, and punch another one to get off it. That's tricky when you're just starting out like they are. Shall we go and say well done?