Functions library
Within hash characters, you can define numerical calculations and string operations. In its simplest form, you can perform addition, subtraction, division, and multiplication. The plugin uses a functions library to assist with calculations, and that library offers many functions, listed below.
The function names on this page use capital letters, but the math library ignores case when it comes to function names.
Some examples:
- {text:#MAX(@e_ccvalue, 64)#}
- {text:#BITAND(@e_ccvalue, 63)#}
- {text:#IF(@e_ccvalue > 64, "High", "Low")#}
Supported Operators
Operator | Description | Version |
|---|---|---|
+ | Additive operator / Unary plus / Concatenate string / Datetime addition | |
& | Concatenate string | |
– | Subtraction operator / Unary minus / Datetime subtraction | |
* | Multiplication operator, can be omitted in front of an open bracket | |
/ | Division operator | |
% | Remainder operator (Modulo) | |
^ | Power operator |
Supported conditional statements
Conditional statement | Description | Version |
|---|---|---|
IF(logical_condition, value_if_true, value_if_false) | Example: | |
SWITCH(expression, val1,result1, [val2,result2], …, [default]) | Example: |
Supported logical and math functions
Function | Description | Version |
|---|---|---|
AND(logical1, [logical2], … | Determine if all conditions are TRUE | |
OR(logical1, [logical2], …) | Determine if any conditions in a test are TRUE | |
NOT(logical) | To confirm one value is not equal to another | |
XOR(logical1, [logical2], …) | Exclusive OR function | |
BOOL(number) | Convert a numerical value to boolean. 0=false, 1=true. | 3.11- |
SUM(number1, [number2],…) | Return sum of numbers supplied | |
AVERAGE(number1, [number2],…) | Return average of numbers supplied | |
MIN(number1, [number2],…) | Return the smallest value from the numbers supplied | |
MAX(number1, [number2],…) | Return the biggest value from the numbers supplied | |
RANGE(number, min, max) | Returs a value that is confined to the defined range. | 3.11- |
MOD(number, divisor) | Get remainder of two given numbers after division operator. | |
ROUND(number, num_digits) ROUND(number, num_digits, rounding_mode) | Returns the rounded approximation of given number. Roundinig modes:
| rounding mode: 4.2- |
FLOOR(number, significance) | Rounds a given number towards zero to the nearest multiple of a specified significance | |
CEILING(number, significance) | Rounds a given number away from zero, to the nearest multiple of a given number | |
POWER(number, power) | Returns the result of a number raised to a given power | |
RAND() | Produces a random number between 0 and 1 | |
SIN(number) | Returns the trigonometric sine of the angle given in radians | |
SINH(number) | Returns the hyperbolic sine of a number | |
ASIN(number) | Returns the arc sine of an angle, in the range of -pi/2 through pi/2 | |
COS(number) | Returns the trigonometric cos of the angle given in radians | |
COSH(number) | Returns the hyperbolic cos of a number | |
ACOS(number) | Returns the arc cosine of an angle, in the range of 0.0 through pi | |
TAN(number) | Returns the tangent of the angle given in radians | |
TANH(number) | Returns the hyperbolic tangent of a number | |
ATAN(number) | Returns the arc tangent of an angle given in radians | |
COT(number) | Returns the cotangent of an angle given in radians. | |
ATAN2(x_number, y_number) | Returns the arctangent from x- and y-coordinates | |
COTH(number) | Returns the hyperbolic cotangent of a number | |
ACOT(number) | Returns the inverse cotangent of a value, defined as acot(x) = atan(1/x). | 3.11- |
SQRT(number) | Returns the correctly rounded positive square root of given number | |
LN(number) | Returns the natural logarithm (base e) of given number | |
EXP(number) | Returns e raised to the power of given number | |
ABS(number) | Returns the absolute value of given number | |
FACT(number) | Returns the factorial of a given number | |
SEC(number) | Returns the secant of an angle given in radians | |
LOG10(number) | Returns the logarithm (base 10) of given number | |
CSC(number) | Returns the cosecant of an angle given in radians | |
PI() | Return value of Pi | |
DEGREES(radians) | Convert radians to degrees | |
RADIANS(degrees) | Convert degrees to radians | |
INT(number) | Returns the Integer value of given number | |
FP(number) | Returns a floating-point value of given number | 4.2- |
DECIMALS(number, maxdecimals) | Returns a floating-point value with the maximum number of decimals. Internally, floating-point values can have many decimal places; this function allows you to reduce the number of decimals, which may be necessary for proper display.
| 4.2- |
RND(min, max) | Returns a random value between min and max. | 4.2- |
Supported Constants
Constant | Description | Version |
|---|---|---|
e | The value of e | |
PI | The value of PI | |
TRUE | The boolean true value | |
FALSE | The boolean false value | |
NULL | The null value |
Supported text functions
Function | Description | Version |
|---|---|---|
LEFT(text, num_chars) | Extracts a given number of characters from the left side of a supplied text string | |
RIGHT(text, num_chars) | Extracts a given number of characters from the right side of a supplied text string | |
MID(text, start_num, num_chars) | Extracts a given number of characters from the middle of a supplied text string | |
REVERSE(text) | Reverse a string | |
ISNUMBER(text) | Check if a value is a number | |
LOWER(text) | Converts all letters in the specified string to lowercase | |
UPPER(text) | Converts all letters in the specified string to uppercase | |
PROPER(text) | Capitalizes words given text string | |
TRIM(text) | Removes extra spaces from text | |
LEN(text) | Returns the length of a text string | |
REPLACE(old_text, start_num, num_chars, new_text) | Replaces characters specified by location in a given text string with another text string | |
SUBSTITUTE(text, old_text, new_text) | Replaces a set of characters with another | |
FIND(find_text, within_text, [start_num]) | Returns the location of a substring in a string (case sensitive) | |
SEARCH(find_text, within_text, [start_num]) | Returns the location of a substring in a string (case insensitive) | |
CONCAT(text1, text2, text3,…) | Combines the text from multiple strings | |
ISBLANK(text) | Returns TRUE when a given string is null or empty, otherwise return FALSE | |
REPT(text, repeat_time) | Repeats characters a given number of times | |
CHAR(char_code) | Return character from ascii code | |
CODE(char) | Returns a ascii code of a character | |
VALUE(text) | Convert numbers stored as text to numbers | |
HEXVALUE(text) | Convert numbers stored as hexadecimal text to numbers. Space characters are ignored, so "01 0A" gives the same result as "010A". Not case-sensitive. | 3.12- |
HEXSTRING(number, num_chars) | Converts an integer to a hexadecimal string. By default (if num_chars is omitted), it returns a two-character hexadecimal string. If a different length is required, this can be specified with num_chars. The result is zero-padded to achieve the desired length. | 4.0- |
LPAD(text, count, pad_character) | Adds pad characters to the left until the number of characters is "count". | 3.11- |
RPAD(text, count, pad_character) | Adds pad characters to the right until the number of characters is "count". | 3.11- |
HHMMSS(value) | Converts a value in milliseconds to a "hh:mm:ss" string. | 3.11- |
HHMM(value) | Converts a value in milliseconds to a "hh:mm" string. | 3.11- |
MMSS(value) | Converts a value in milliseconds to a "mm:ss" string. | 3.11- |
COUNT(text, text) | Returns the count of how many times a specific string appears in another string, case-insensitive. Examples:
| 4.2- |
STR(something) | Returns "something" as a string value. "Something" can be any type of value: string, integer, floating-point or boolean. | 4.2- |
VARTYPE(something) | Returns the value type of the argument. Primarily used to get the type of a variable.
| 4.2- |
LOADFILE(path) | Returns the content from the referenced file. If a row number is specified, only that row is returned; otherwise, the entire file is returned. The first row in the file is numbered 1. With a myfile.txt containing the letters A, B, and C on separate rows, the following actions produce the outlined outcomes.
| 4.2- |
FILESAFE(filename) | Returns a string that is safe to be used as a file name. Characters not allowed in a file name are replaced with underscores. A common use for this function might be to date-stamp a file with the current date and time as the file name. A word of caution: if you use a date format with slashes, like the US date format 14/1/2026, you need to handle the file name separately from the full path. If you pass a full path to the function (C:/Users/userid/Documents/Trevliga Spel/14/01/2026 8:53:01 pm.txt), it can't distinguish the boundary between the directory path and the file name because slashes are used in both parts. You need to first store the date in a variable, make the variable file-safe, and then concatenate it with the full path.
| 4.2- |
Supported list functions
List functions handle comma-separated lists and include methods to get, set, add, or remove list items, as well as count the items. The first item in a list has index 1. Item texts must be enclosed in quotation marks to prevent the Math library from treating them as variables.
Please note that methods that change a list in a variable do not automatically update the variable's value; you need to assign the method's result to the variable.
{@l_MyVar:#additem(@l_MyVar,"all")#}
Function | Description | Version |
|---|---|---|
GETITEM(index, list) | Returns the item at the specified index in the list. If the index is out of bounds, an empty item is returned. | 4.2- |
SETITEM(index, list, newItem) | Returns a new list with the new item at the specified index, replacing any item previously at that position. If the index exceeds the current number of items in the list, the list will be expanded with empty items to reach the necessary item count. |
|
ADDITEM(list, newItem) | Returns a new list with the new item appended to the end. | 4.2- |
INSERTITEM(index, list, newItem) | Returns a new list with the new item inserted at the specified index. If the index exceeds the current number of items in the list, the list will be expanded with empty items to reach the necessary item count. | 4.2- |
REMOVEITEM(index, list) | Returns a new list with the item at the specified index removed. | 4.2- |
REPLACEITEM(list, oldItem, newItem) | Returns a new list with the old item replaced by the new item. The function is case sensitive. If the item is not found, the list is returned unchanged. | 4.2- |
ITEMCOUNT(list) | Returns the number of items in a list. | 4.2- |
ITEMINDEX(list, item) | Returns the index of the specified item. The function is case sensitive. If the item is not found, 0 is returned. | 4.2- |
Supported date and time functions
Date and time functions return information formatted according to the language settings of the computer. For functions returning strings, examples are provided for the results in US English and Swedish.
The DATETIME function can be used with an index for a format, a format name, or a custom format based on the C# DateTime Standard or Custom format specifiers.
Function | Description | Version |
|---|---|---|
DATETIME() | Returns the full date and time: | 4.2- |
DATETIME(2) | Returns a short date:" |
|
DATETIME(3) | Returns a long date: | 4.2- |
DATETIME(4) | Returns time without seconds: | 4.2- |
DATETIME(5) | Returns time with seconds: | 4.2- |
DATETIME(6) | Returns the year: | 4.2- |
DATETIME(7) | Returns the ordinal number of the month.: | 4.2- |
DATETIME(8) | Returns the abbreviated name of the month: | 4.2- |
DATETIME(9) | Returns the name of the month: |
|
DATETIME(10) | Returns the current day's number in the month: |
|
DATETIME(11) | Returns the current day's number in the week: |
|
DATETIME(12) | Returns the short name of the weekday: |
|
DATETIME(13) | Returns the name of the weekday: |
|
DATETIME(14) | Returns the current day's number in the year: |
|
DATETIME(15) | Returns the hour in 12-hour or 24-hour format without the AM/PM indicator. |
|
DATETIME(16) | Returns the minutes: |
|
DATETIME(17) | Returns the seconds: |
|
DATETIME(_custom_) |
|
Supported bitwise functions
Function | Description | Version |
|---|---|---|
BITAND(number, number) | Returns an integer that is the result of a bitwise AND operation. | |
BITOR(number, number) | Returns an integer that is the result of a bitwise OR operation. | |
BITXOR(number, number) | Returns an integer that is the result of a bitwise XOR operation | |
BITNOT(number) | Returns an integer that is the result of a bitwise NOT operation | |
BITLSHIFT(number, steps) | Returns an integer that is the result of a bitwise left shift the number of steps defined | |
BITRSHIFT(number, steps) | Returns an integer that is the result of a bitwise right shift the number of steps defined | |
BITGET(number, position) | Returns an integer that is either 0 or 1 depending on the bit at the specified position. The least significant bit is at position 0. |
|
BITSET(number, position, bitvalue) | Returns an integer that is the number with the bit at the specified position set to the specified bit value. The least significant bit is at position 0. |
|