Script Math
Within hash characters, you can define math equations. In its simplest form, you can use addition, subtraction, division, and multiplication. The plugin uses a math library to help with the calculations, and that math library has a lot of functions, as listed below. I have not verified that the plugin script validator and the math library work together in all available functions, but the essential functions work.
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) | Returns the rounded approximation of given number using half-even rounding mode | |
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 |
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- |
PART(index, text) | Returns the item at the specified index in a comma-separated list. The list should consist of items separated by commas, for example, "A,B,C,D". The first item in the list has index 1. PART(3, "A,B,C,D") will return "C". An index below 1 will return the first item in the list. An index greater than the number of items in the list will return the last item in the list. | 4.1.0.1- |
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 |