128
edits
m (→fetchvar) |
(Converted example format to match actual usage) |
||
Line 108: | Line 108: | ||
==== abs ==== | ==== abs ==== | ||
''number'' '''abs'''(''number'' value) | ''number'' '''abs'''(''number'' value) | ||
Returns the absolute value of a number | Returns the absolute value of a number | ||
Example: | Example: | ||
abs(1) | <nowiki>{{ abs(1) }} <!-- Returns 1 --></nowiki> | ||
abs(-1) | <nowiki>{{ abs(-1) }} <!-- Returns 1 --></nowiki> | ||
==== ceil ==== | ==== ceil ==== | ||
''number'' '''ceil'''(''number'' value) | ''number'' '''ceil'''(''number'' value) | ||
Returns the ceiling of a number. | Returns the ceiling of a number. | ||
Example: | Example: | ||
ceil(1.4) | <nowiki>{{ ceil(1.4) }} <!-- Returns 2 --></nowiki> | ||
ceil(1.9) | <nowiki>{{ ceil(1.9) }} <!-- Returns 2 --></nowiki> | ||
==== div ==== | ==== div ==== | ||
''number'' '''div'''(''number'' dividend, ''number'' divisor) | ''number'' '''div'''(''number'' dividend, ''number'' divisor) | ||
Returns the integer quotient when dividing dividend with divider. | Returns the integer quotient when dividing dividend with divider. | ||
Example: | Example: | ||
div(10, 3) | <nowiki>{{ div(10, 3) }} <!-- Returns 3 --></nowiki> | ||
==== floor ==== | ==== floor ==== | ||
''number'' '''floor'''(''number'' value) | ''number'' '''floor'''(''number'' value) | ||
Returns the floor of a number. | Returns the floor of a number. | ||
Example: | Example: | ||
floor(1.1) | <nowiki>{{ floor(1.1) }} <!-- Returns 1 --></nowiki> | ||
floor(1.9) | <nowiki>{{ floor(1.9) }} <!-- Returns 1 --></nowiki> | ||
==== max ==== | ==== max ==== | ||
''number'' '''max'''(''number'' value1, ''number'' value2[, ''number'' ...]) | ''number'' '''max'''(''number'' value1, ''number'' value2[, ''number'' ...]) | ||
Returns the numerically highest value of the given arguments. At least two arguments are required. | Returns the numerically highest value of the given arguments. At least two arguments are required. | ||
Example: | Example: | ||
max(3, 5) | <nowiki>{{ max(3, 5) }} <!-- Returns 5 --></nowiki> | ||
max(3, 1.2, 5, 5.1) | <nowiki>{{ max(3, 1.2, 5, 5.1) }} <!-- Returns 5.1 --></nowiki> | ||
==== min ==== | ==== min ==== | ||
''number'' '''min'''(''number'' value1, ''number'' value2[, ''number'' ...]) | ''number'' '''min'''(''number'' value1, ''number'' value2[, ''number'' ...]) | ||
Returns the numerically lowest value of the given arguments. At least two arguments are required. | Returns the numerically lowest value of the given arguments. At least two arguments are required. | ||
Example: | Example: | ||
min(3, 5) | <nowiki>{{ min(3, 5) }} <!-- Returns 3 --></nowiki> | ||
min(3, 1.2, 5, 5.1) | <nowiki>{{ min(3, 1.2, 5, 5.1) }} <!-- Returns 1.2 --></nowiki> | ||
==== mod ==== | ==== mod ==== | ||
''number'' '''mod'''(''number'' dividend, ''number'' divisor) | ''number'' '''mod'''(''number'' dividend, ''number'' divisor) | ||
Returns the reminder when dividing dividend with divider. | Returns the reminder when dividing dividend with divider. | ||
Example: | Example: | ||
mod(10, 3) | <nowiki>{{ mod(10, 3) }} <!-- Returns 1 --></nowiki> | ||
==== pow ==== | ==== pow ==== | ||
''number'' '''pow'''(''number'' base, ''number'' exp) | ''number'' '''pow'''(''number'' base, ''number'' exp) | ||
Returns base to the power of exp. | Returns base to the power of exp. | ||
Example: | Example: | ||
pow(3, 2) | <nowiki>{{ pow(3, 2) }} <!-- Returns 9 --></nowiki> | ||
pow(2, 3) | <nowiki>{{ pow(2, 3) }} <!-- Returns 8 --></nowiki> | ||
==== random ==== | ==== random ==== | ||
''number'' '''random'''(''number'' start, ''number'' end) | ''number'' '''random'''(''number'' start, ''number'' end) | ||
Returns a random integer from the set of integers starting at start and ending at end. | Returns a random integer from the set of integers starting at start and ending at end. | ||
Example: | Example: | ||
random(1, 10) | <nowiki>{{ random(1, 10) }} <!-- Returns a random integer from 1 to 10 --></nowiki> | ||
random(0, 100) | <nowiki>{{ random(0, 100) }} <!-- Returns a random integer from 0 to 100 --></nowiki> | ||
==== round ==== | ==== round ==== | ||
''number'' '''round'''(''number'' value[, ''number'' precision]) | ''number'' '''round'''(''number'' value[, ''number'' precision]) | ||
Returns a rounded number with the given precision. If precision isn't specified it will return an integer. | Returns a rounded number with the given precision. If precision isn't specified it will return an integer. | ||
Example: | Example: | ||
round(2.4) | <nowiki>{{ round(2.4) }} <!-- Returns 2 --></nowiki> | ||
round(2.5) | <nowiki>{{ round(2.5) }} <!-- Returns 3 --></nowiki> | ||
round(2.55, 1) | <nowiki>{{ round(2.55, 1) }} <!-- Returns 2.6 --></nowiki> | ||
==== sqrt ==== | ==== sqrt ==== | ||
''number'' '''sqrt'''(''number'' value) | ''number'' '''sqrt'''(''number'' value) | ||
Returns the square root of value. | Returns the square root of value. | ||
Example: | Example: | ||
sqrt(9) | <nowiki>{{ sqrt(9) }} <!-- Returns 3 --></nowiki> | ||
=== Miscellaneous === | === Miscellaneous === | ||
==== date ==== | ==== date ==== | ||
''string'' '''date'''(''string'' format[, ''string'' time]) | ''string'' '''date'''(''string'' format[, ''string'' time]) | ||
Returns date and time according to the first argument. The format syntax is the same as PHP's date(). The optional argument may be a timestamp or string with date. | Returns date and time according to the first argument. The format syntax is the same as PHP's date(). The optional argument may be a timestamp or string with date. | ||
Example: | Example: | ||
date("Y-m-d") | <nowiki>{{ date("Y-m-d") }} <!-- Returns current date e.g. "2007-11-20" --></nowiki> | ||
date("H:i:s") | <nowiki>{{ date("H:i:s") }} <!-- Returns current time, e.g. "19:50:37" --></nowiki> | ||
date("Y-m-d", "1995-10-03T20:30:37") | <nowiki>{{ date("Y-m-d", "1995-10-03T20:30:37") }} <!-- Returns date "1995-10-03" --></nowiki> | ||
==== fetchvar ==== | ==== fetchvar ==== | ||
''string'' '''fetchvar'''(''string'' variable) | ''string'' '''fetchvar'''(''string'' variable) | ||
Returns the variable given as an argument. | Returns the variable given as an argument. | ||
Example: | Example: | ||
@test1 = "Hi!" | <nowiki>{{ @test1 = "Hi!" }}</nowiki> | ||
fetchvar("@test1") | <nowiki>{{ fetchvar("@test1") }} <!-- Returns "Hi!" --></nowiki> | ||
fetchvar("@test" + 1) | <nowiki>{{ fetchvar("@test" + 1) }} <!-- Returns "Hi!" --></nowiki> | ||
@test2 = 1 | <nowiki>{{ @test2 = 1 }}</nowiki> | ||
fetchvar("$latestwatched_id" + @test2 + "_aname") | <nowiki>{{ fetchvar("$latestwatched_id" + @test2 + "_aname") }} <!-- Returns the name of the latest watched anime --></nowiki> | ||
==== if ==== | ==== if ==== | ||
''Alias of [[#notempty|notempty() | ''Alias of [[#notempty|notempty()]]'' | ||
==== lc ==== | ==== lc ==== | ||
''Alias of [[#lowercase|lowercase() | ''Alias of [[#lowercase|lowercase()]]'' | ||
==== length ==== | ==== length ==== | ||
''number'' '''length'''(''string'' value) | ''number'' '''length'''(''string'' value) | ||
Returns the number of characters of the string. | Returns the number of characters of the string. | ||
Example: | Example: | ||
length("Foobar") | <nowiki>{{ length("Foobar") }} <!-- Returns 6 --></nowiki> | ||
length("") | <nowiki>{{ length("") }} <!-- Returns 0 --></nowiki> | ||
length("Foo bar.") | <nowiki>{{ length("Foo bar.") }} <!-- Returns 8 --></nowiki> | ||
==== lowercase ==== | ==== lowercase ==== | ||
''string'' '''lowercase'''(''mixed'' value[, ''string'' options]) | ''string'' '''lowercase'''(''mixed'' value[, ''string'' options]) | ||
If only first argument is specified it converts all the characters to lowercase. The second argument may be "first" or "words". If it is "first" only the string's first character will be converted. If it is set to "words", every word's first character will be converted. | If only first argument is specified it converts all the characters to lowercase. The second argument may be "first" or "words". If it is "first" only the string's first character will be converted. If it is set to "words", every word's first character will be converted. | ||
Example: | Example: | ||
lowercase("Foo Bar") | <nowiki>{{ lowercase("Foo Bar") }} <!-- Returns "foo bar" --></nowiki> | ||
lowercase("Foo Bar", "first") | <nowiki>{{ lowercase("Foo Bar", "first") }} <!-- Returns "foo Bar" --></nowiki> | ||
lowercase("Foo BAR", "words") | <nowiki>{{ lowercase("Foo BAR", "words") }} <!-- Returns "foo bAR" --></nowiki> | ||
==== notempty ==== | ==== notempty ==== | ||
''mixed'' '''notempty'''(''mixed'' value[, ''mixed'' true[, ''mixed'' false]]) | ''mixed'' '''notempty'''(''mixed'' value[, ''mixed'' true[, ''mixed'' false]]) | ||
Checks if the first argument is not empty. Returns TRUE or FALSE if the optional arguments aren't specified. If they are specified it returns the second argument if TRUE and the third argument if FALSE. | |||
Example: | Example: | ||
notempty("") | <nowiki>{{ notempty("") }} <!-- Returns false --></nowiki> | ||
notempty("Foobar") | <nowiki>{{ notempty("Foobar") }} <!-- Returns true --></nowiki> | ||
notempty(6 > 2) | <nowiki>{{ notempty(6 > 2) }} <!-- Returns true --></nowiki> | ||
notempty("", "Not empty", "Empty") | <nowiki>{{ notempty("", "Not empty", "Empty") }} <!-- Returns "Empty" --></nowiki> | ||
==== padding ==== | ==== padding ==== | ||
''string'' '''padding'''(''mixed'' value, ''number'' padding[, ''string'' align]) | ''string'' '''padding'''(''mixed'' value, ''number'' padding[, ''string'' align]) | ||
Takes value and adds padding on left side if third argument isn't specified. Third argument is optional and may be "left" or "right" and specifies the padding alignment. Second argument specifies the padding width. | Takes value and adds padding on left side if third argument isn't specified. Third argument is optional and may be "left" or "right" and specifies the padding alignment. Second argument specifies the padding width. | ||
Example: | Example: | ||
padding("2.40", 6) | <nowiki>{{ padding("2.40", 6) }} <!-- Returns " 2.40" --></nowiki> | ||
padding("12.40", 6) | <nowiki>{{ padding("12.40", 6) }} <!-- Returns " 12.40" --></nowiki> | ||
padding("2.40", 6, "left") | <nowiki>{{ padding("2.40", 6, "left") }} <!-- Returns "2.40 " --></nowiki> | ||
padding("1220.40", 6) | <nowiki>{{ padding("1220.40", 6) }} <!-- Returns "1220.40" --></nowiki> | ||
==== precision ==== | ==== precision ==== | ||
''string'' '''precision'''(''number'' value, ''number'' precision) | ''string'' '''precision'''(''number'' value, ''number'' precision) | ||
Returns string containing value with a fixed number of decimals. | Returns string containing value with a fixed number of decimals. | ||
Example: | Example: | ||
precision(5, 2) | <nowiki>{{ precision(5, 2) }} <!-- Returns "5.00" --></nowiki> | ||
precision(5.25, 1) | <nowiki>{{ precision(5.25, 1) }} <!-- Returns "5.2" --></nowiki> | ||
precision(5.26, 1) | <nowiki>{{ precision(5.26, 1) }} <!-- Returns "5.3" --></nowiki> | ||
precision(5.24, 1) | <nowiki>{{ precision(5.24, 1) }} <!-- Returns "5.2" --></nowiki> | ||
==== truncate ==== | ==== truncate ==== | ||
''string'' '''truncate'''(''string'' value, ''number'' length[, ''string'' appendage]) | ''string'' '''truncate'''(''string'' value, ''number'' length[, ''string'' appendage]) | ||
Returns the string truncated to specified length. If third argument is specified it will be appended to the returned string if it's truncated. | Returns the string truncated to specified length. If third argument is specified it will be appended to the returned string if it's truncated. | ||
Example: | Example: | ||
truncate("Foobar", 3) | <nowiki>{{ truncate("Foobar", 3) }} <!-- Returns "Foo" --></nowiki> | ||
truncate("Foobar", 4, "..") | <nowiki>{{ truncate("Foobar", 4, "..") }} <!-- Returns "Fo.." --></nowiki> | ||
truncate("Foob", 4, "..") | <nowiki>{{ truncate("Foob", 4, "..") }} <!-- Returns "Foob" --></nowiki> | ||
==== uc ==== | ==== uc ==== | ||
''Alias of [[#uppercase|uppercase() | ''Alias of [[#uppercase|uppercase()]]'' | ||
==== uppercase ==== | ==== uppercase ==== | ||
''string'' '''uppercase'''(''mixed'' value[, ''string'' options]) | ''string'' '''uppercase'''(''mixed'' value[, ''string'' options]) | ||
If only first argument is specified it converts all the characters to uppercase. The second argument may be "first" or "words". If it is "first" only the string's first character will be converted. If it is set to "words", every word's first character will be converted. | If only first argument is specified it converts all the characters to uppercase. The second argument may be "first" or "words". If it is "first" only the string's first character will be converted. If it is set to "words", every word's first character will be converted. | ||
Example: | Example: | ||
uppercase("Foo Bar") | <nowiki>{{ uppercase("Foo Bar") }} <!-- Returns "FOO BAR" --></nowiki> | ||
uppercase("foo bar", "first") | <nowiki>{{ uppercase("foo bar", "first") }} <!-- Returns "Foo bar" --></nowiki> | ||
uppercase("foo baR", "words") | <nowiki>{{ uppercase("foo baR", "words") }} <!-- Returns "Foo BaR" --></nowiki> | ||
[[Category:SigServer]] | [[Category:SigServer]] |
edits