Expression Functions

Parent Previous Next

Expression Functions

Expressions support the use of a set of functions.  These functions cannot be used outwith expressions as per general functions (unless used as an array argument).  However, expressions can also contain general and item functions.  Expression functions do not require % symbols to define them.


The supported list of Expression Functions is as follows:

Abs

This returns the absolute value (positive part) of a number


Syntax

ABS(val)

Parameters

val

An expression that resolves to a number (integer).


Example

ABS(-7) = 7



Either

This randomly returns one of the two input parameters.  The function works on both numbers, and text values.  This function is basically the same as the ONEOF function, but can only take two parameters.


Syntax

EITHER(val1, val2)

Parameters

val1

An expression that resolves to a number (integer) or text (string).

val2

An expression that resolves to a number (integer) or text (string).


Example

EITHER(%Player%.Name, "") = ""



Instr

This function returns an integer specifying the start position of the first occurrence of one string within another.


Syntax

INSTR(str1, str2)

Parameters

str1

An expression that resolves to text (string).  This is the string being searched.

str2

An expression that resolves to text (string).  This is the string expression sought.


Example

INSTR("One two three", "t") = 5

Note that this is not case sensitive, so INSTR("hello","E") will also return 2.


This function returns 0 (zero) if str2 does not exist within str1.




If

This function evaluates the first parameter.  If this evaluates to True it returns the second parameter.  If not, it returns the third parameter.


Syntax

IF(Test, TruePart, FalsePart)

Parameters

Test

An expression that resolves to True or False


The test conditions supported are <, <=, =, >=, >, and <>.


Test conditions can be ANDed and ORed together using AND and OR

TruePart

An expression that resolves to a number (integer) or text (string).  Returned if Test evaluates to True.

FalsePart

An expression that resolves to a number (integer) or text (string).  Returned if Test evaluates to False.


Examples

IF(%Player%.Held.Count = 0, "none", "at least one")

IF(%Player% = "Character1" AND %Player%.Held.Count > 0, "Wow!", "")



LCase

This returns a text value in Lower Case.


Syntax

LCASE(str)

Parameters

str

An expression that resolves to text (string).


Example

LCASE("Testing") = "testing"



Left

This returns the requested number of characters from a piece of text, starting from the left.


Syntax

LEFT(str, length)

Parameters

str

An expression that resolves to text (string).


Example

LEFT("Testing", 4) = "Test"



Len

This returns the length of a piece of text.


Syntax

LEN(str)

Parameters

str

An expression that resolves to text (string).


Example

LEN("Testing") = 7



Max

This returns the maximum of two numbers.


Syntax

MAX(val1, val2)

Parameters

val1

An expression that resolves to a number (integer).

val2

An expression that resolves to a number (integer).


Example

MAX(%Player%.Held.Count, 5) = 5



Mid

This returns the requested number of characters from a piece of text, starting at the specified location.


Syntax

MID(str, start, length)

Parameters

str

An expression that resolves to text (string).

start

An expression that resolves to a number (integer) for the start position in the text.  This parameter is 0 indexed, i.e. to return characters starting from the second character you would supply the value 1.

length

An expression that resolves to a number (integer) for the number of characters to be returned.


Example

MID("Testing", 2, 4) = "stin"



Min

This returns the minimum of two numbers.


Syntax

MIN(val1, val2)

Parameters

val1

An expression that resolves to a number (integer).

val2

An expression that resolves to a number (integer).


Example

MIN(3, %variable%) = 3



OneOf

This randomly returns one of the supplied input parameters.  The function works on both numbers, and text values.  Any number of parameters can be supplied.  This function is basically the same as the EITHER function, but can take more parameters.


Syntax

ONEOF(val1, val2, val3, ...)

Parameters

val1

An expression that resolves to a number (integer) or text (string).

val2

An expression that resolves to a number (integer) or text (string).

val3

An expression that resolves to a number (integer) or text (string).


Example

ONEOF("one", "two", "three", "four", "five") = "four"



PCase

This returns a text value in Proper (i.e. first letter capitalised, the rest lower) Case.


Syntax

PCASE(str)

Parameters

str

An expression that resolves to text (string).


Example

PCASE("testing") = "Testing"



Rand

This returns a random number between two supplied values.


Syntax

RAND(val1, val2)

Parameters

val1

An expression that resolves to a number (integer).

val2

An expression that resolves to a number (integer).


Example

RAND(10, 15) = 11



Replace

This function replaces all instances of a piece of text with another, inside another piece of text.


Syntax

REPLACE(Source, Find, Replace)

Parameters

Source

An expression that resolves to text (string).  This will be returned by the function, with all instances of Find replaced to Replace.

Find

An expression that resolves to text (string).  This is the text to search for.

Replace

An expression that resolves to text (string).  This is the text to replace any found text.


Example

REPLACE("one two three", "two", "TWO") = "one TWO three"



Right

This returns the requested number of characters from a piece of text, starting from the right.


Syntax

RIGHT(str, length)

Parameters

str

An expression that resolves to text (string).


Example

RIGHT("Testing", 4) = "ting"



Str

This converts a number to text.


Syntax

STR(val)

Parameters

val

An expression that resolves to a number (integer).


Example

VAL(7) = "7"



UCase

This returns a text value in Upper Case.


Syntax

UCASE(str)

Parameters

str

An expression that resolves to text (string).


Example

UCASE("Testing") = "TESTING"



Val

This converts text to a number.  If the text does not represent a number, zero will be returned.


Syntax

VAL(str)

Parameters

str

An expression that resolves to a number (integer) or text (string).


Example

VAL("7") = 7