Template:Random/doc

From Tardis Wiki, the free Doctor Who reference

{{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}} = 925

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.

Anneke Wills: [ Patrick Troughton, Michael Craze, Frazer Hines and I ] did the last of the historical stories, so it's been a long time — except of course now the new ones and David Tennant and popping back to Madame de Pompadour and so forth. So for me it was lovely to hear they'd written [Resistance] in this last war. I always liked the historicals best, you see.
Lisa Bowerman: . . . I knew this story would probably work because . . . there was an adaptation of a Lance Parkin novel called Just War which was set on Guernsey during the Second World War occupation. And it actually is a very, very powerful era to deal with because it's about the rights and wrongs of war . . . [H]ow people responded to Just War I think will be the same as this, because it's a real tangible, understandable threat, as opposed some sort of a surreal threat of a Cyberman or whatever.
John Sackville: Yes, I think that's what I wasn't saying earlier.
BFX: Resistance

Substitutive use

In some applications, you want to generate a random number, but you want that random number to "stick" on the page. That is, you don't want the number to change each time you reload the page. To do this, you have to substitute the template:

In this case, you would use the following syntax:

{{subst:random|1000}}

No matter how many times you reload the page, these random numbers will stick: Expression error: Unrecognised punctuation character "{"

  • Expression error: Unrecognised punctuation character "{", 594, Expression error: Unrecognised punctuation character "{", 594, 886