Hľadaj
MENU
  • Výrazy / Skriptovací jazyk
  • Používatelia a povolenia
  • Záloha, obnova zálohy, reset na továrenské nastavenia
  • Výrazy / Skriptovací jazyk

    Multi-line scripting language with syntax highlighting, usable in smart rules Equation, Formula and Script, and also in Modbus and Packet parser interfaces.

    800

    Basics

    Association

    Mu := Se + 2;

    Multi-line algorithm

    Each line is divided by semicolon

    Last := Current;
    Current := 0;

    Returned value

    • Result of last line of code

    • RETURN(expression) stops execution of algorighm and returns content inside brackets

    (Co2 > 800) AND (Wind < 10);
    equals:
    RETURN((CO2 > 800) and (Wind < 10));

    Temporary variable

    Lives within the single execution of the script.

    VAR X := 5;

    IF clause

    Excel style

    IF(logical_expression, value_if_true, value_if_false);
    IF(logical_expression, value_if_true);

    Multi-line style

    IF X < 5
      RETURN(1);
    ELSEIF X > 10
      RETURN(3);
    ELSE
      RETURN(0);
    END

    Switch

    Testuje výraz proti zoznamu prípadov a vracia zodpovedajúcu hodnotu prvého porovnávacieho prípadu s predvolenou hodnotou, ak nie je splnené nič iné.

    SWITCH(expression, case1, value1, [case2, ...], [value2, ...], default_value)

    Example:

    300
    SWITCH( MODBUSR(H, 168, UInt16),
      0, 0,
      0x0002, 1,
      0x0004, 2,
      0x0008, 3,
      0x0010, 4,
      0x0040, 5,
      0x0800, 6,
      NaN)

    Loop

    LOOP / WHILE ... repeats a series of commands based on a specified condition until that condition is met.
    CONTINUE ... skips the execution of commands and continues to the next cycle.
    BREAK ... terminates the loop.

    Example with condition at the beginning:

    int i := 10;
    while i > 0
        i := i - 1;
        
        if i > 5
            continue;
        else
            break;
        end
    loop

    Example with condition at the end:

    int i := 10;
    do
        i := i + i;
    loop while i < 10

    NaN (not a number) value

    NaN can be returned as a value in case real value is not known.

    IF Temperature > 250 
      RETURN(NaN);

    ISNAN(expression) function
    Returns TRUE if expression is not a number.

    ISNULL

    Returns true if the parameter is NULL, false otherwise. Used for String and Bytearray types. Example: if XML element is not found, returned value ISNULL.

    The syntax of the function is:

    ISNULL(object)

    Sleep

    Sleeps the script for number of miliseconds. Use only in very specific cases.

    SLEEP(5);

    Comments

    New line starting with character #

    # comment

    Numeric literals

    Hexadecimálne čísla

    Výrazy môžu tiež interpretovať hexadecimálne čísla. Vyžaduje sa predpona 0x a zvyšok nerozlišuje veľké a malé písmená.

    0x0A = 10

    0xA0A0   (41120)
    0xa0a0   (41120)

    Binary numbers

    0b1010 = 10

    0b10101010   (170)

    Matematické výrazy

    +, -, *, /

    (20.5 + 9.5) / 2    (15)

    Logické výrazy

    AND, OR, !, =, !=, >, <

    (!IsRaining OR (Wind>30))
    MultiValueSwitchState != 2 (Not equal to 2)

    Funkcie

    LINEAR

    Vráti lineárne upravenú hodnotu - lineárnu interpoláciu.

    LINEAR(input, value1_input, value1_output, value2_input, value2_output, [type])

    Parametre

    • input … vstupná hodnota
    • value1_input … hodnota na vstupe na dolnej hranici
    • value1_output … hodnota na výstupe na dolnej hranici
    • value2_input … hodnota na vstupe na hornej hranici
    • value2_output … hodnota na výstupe na hornej hranici
    • [type] … voliteľný parameter. Definuje aký má byť výsledok, keď vstupná hodnota je mimo rozsahu value1_input ↔︎ value2_input:
      • bez parametra (to isté ako s parametrom BOUNDS) … Ak je vstupná hodnota mimo definovaného rozsahu, výstupná hodnota bude jedna z extrémov (minimálna alebo maximálna)
      • INFINITE … Ak je vstupná hodnota mimo definovaného rozsahu, výsledok je extrapolovaná hodnota
      • STRICT … Ak je vstupná hodnota mimo definovaného rozsahu, výstupná hodnota bude NaN (nie číslo)

    Examples

    Example 1: LINEAR(250,  0,0,  50,500)   (Result is 25°C)
    
    Example 2: LINEAR(Co2,  400,0,  1200,1)
              (If value from Co2 sensor is 400ppm, output for air recovery will be 0%. 
               If Co2 is 1200, output will be 100%. And if e.g. Co2=800, output will be 50%)
    800

    Príklady rôznych atribútov [type]:

    • input = 11
    • value1_input = 0, value1_output = 400
    • value2_input = 10, value2_output = 2000
    • výsledok pre rôzne parametre [type]:
      • BOUNDS (predvolená hodnota) = 2000
      • INFINITE = 2160
      • STRCT = NaN

    HYSTERESIS

    Hysteresis can be used to filter signals so that the output reacts less rapidly than it otherwise would by taking recent system history into account. For example, a thermostat controlling a heater may switch the heater on when the temperature drops below A, but not turn it off until the temperature rises above B.

    Returns 0 or 1.

    HYSTERESIS(value, upper_bound, lower_bound, upper_output, lower_output, last_value)

    Example: maintain a temperature of 20 °C within 2 ºC hysteresis range. Turn the heater on when the temperature drops to below 18 °C and off when the temperature exceeds 22 °C).

    heater := HYSTERESIS(temperature,   22, 18,   0, 1,   heater);

    Matematické funkcie

    MIN

    Funkcia MIN vracia minimum zo zadaných číselných hodnôt. Akceptuje 1 až 100 argumentov alebo jednu kolekciu. Hodnoty NaN a NULL sa ignorujú.

    MIN( n1, n2, n3, …)
    MIN( collection )

    Examples:

    MIN(40, 80)  		= 40
    MIN(2, 2, 6) 		= 2
    MIN(80, NAN)		= 80
    MIN(NAN, NAN)		= NaN
    
    VAR data := {10, 20, 30}; MIN(data) 	= 10
    MIN({1, 2, 3})							= 1
    MIN({1, NaN, 3})						= 1
    
    VAR d1 := DATETIME(2014, 12, 8, 0, 0, 0, 0, DateTimeKind.Utc);
    VAR d2 := DATETIME(2015, 12, 8, 0, 0, 0, 0, DateTimeKind.Utc);
    MIN(d1, d2)			... Result is d1

    MINSTRICT

    Funkcia MINSTRICT vracia minimum zo zadaných číselných hodnôt. Akceptuje 1 až 100 argumentov alebo jednu kolekciu. Ak je niektorá zo zadaných hodnôt NaN alebo NULL, funkcia vráti hodnotu NaN/NULL.

    MINSTRICT( n1, n2, n3, …)
    MINSTRICT( collection )

    Examples:

    MINSTRICT(40, 80)  		= 40
    MINSTRICT(2, 2, 6) 		= 2
    MINSTRICT(80, NAN)		= NaN
    MINSTRICT(NAN, NAN)		= NaN
    
    VAR data := {10, 20, 30}; MINSTRICT(data) 	= 10
    MINSTRICT({1, 2, 3})						= 1
    MINSTRICT({1, NaN, 3})						= NaN
    
    VAR d1 := DATETIME(2014, 12, 8, 0, 0, 0, 0, DateTimeKind.Utc);
    VAR d2 := DATETIME(2015, 12, 8, 0, 0, 0, 0, DateTimeKind.Utc);
    MINSTRICT(d1, NULL, d2)		... Result is NULL

    MAX

    Funkcia MAX vráti maximum zo zadaných číselných hodnôt. Akceptuje 1 až 100 argumentov alebo jednu kolekciu. Hodnoty NaN a NULL sa ignorujú.

    MAX( n1, n2, n3, …)
    MAX( collection )

    Examples:

    MAX(40, 80)  			= 80
    MAX(2, 2, 6) 			= 6
    MAX(80, NAN)			= 80
    MAX(NAN, NAN)			= NaN
    
    VAR data := {10, 20, 30}; MAX(data) = 30
    MAX({1, 2, 3})						= 3
    MAX({1, NaN, 3})					= 3
    
    VAR d1 := DATETIME(2014, 12, 8, 0, 0, 0, 0, DateTimeKind.Utc);
    VAR d2 := DATETIME(2015, 12, 8, 0, 0, 0, 0, DateTimeKind.Utc);
    MAX(d1, d2)				... Result is d2

    MAXSTRICT

    Funkcia MAXSTRICT vráti maximum zo zadaných číselných hodnôt. Akceptuje 1 až 100 argumentov alebo jednu kolekciu. Ak je niektorá zo zadaných hodnôt NaN alebo NULL, funkcia vráti hodnotu NaN/NULL.

    MAXSTRICT( n1, n2, n3, …)
    MAXSTRICT( collection )

    Examples:

    MAXSTRICT(40, 80)  			= 80
    MAXSTRICT(2, 2, 6) 			= 6
    MAXSTRICT(80, NAN)			= NaN
    MAXSTRICT(NAN, NAN)			= NaN
    
    VAR data := {10, 20, 30}; MAXSTRICT(data) 	= 30
    MAXSTRICT({1, 2, 3})				= 3
    MAXSTRICT({1, NaN, 3})				= NaN
    
    VAR d1 := DATETIME(2014, 12, 8, 0, 0, 0, 0, DateTimeKind.Utc);
    VAR d2 := DATETIME(2015, 12, 8, 0, 0, 0, 0, DateTimeKind.Utc);
    MAXSTRICT(d1, NULL, d2)		... Result is NULL

    AVG

    Funkcia AVG vypočíta priemer (priemer) poskytnutých číselných hodnôt. Akceptuje 1 až 100 argumentov alebo jednu kolekciu. Hodnoty NaN sa ignorujú.

    AVG( n1, n2, n3, …)
    AVG( collection )

    Examples:

    AVG(40, 80)  		= 60
    AVG(2, 2, 6) 		= 3.3333
    AVG(80, NAN)		= 80
    AVG(‘a’, ‘c’)		= ‘b’
    AVG(NAN, NAN)		= NaN
    
    
    VAR data := {10, 20, 30}; AVG(data) 	= 20
    AVG({1, 2, 3})							= 2
    AVG({1, NaN, 3})						= 2

    AVGSTRICT

    Funkcia AVGSTRICT vypočíta priemer (priemer) poskytnutých číselných hodnôt. Akceptuje 1 až 100 argumentov alebo jednu kolekciu. Ak niektorá zo zadaných hodnôt nie je číslo, funkcia vráti NaN.

    AVGSTRICT( n1, n2, n3, …)
    AVGSTRICT( collection )

    Examples:

    AVGSTRICT(40, 80)  		= 60
    AVGSTRICT(2, 2, 6) 		= 3.3333
    AVGSTRICT(80, NAN)		= NaN
    AVGSTRICT(NAN, NAN)		= NaN
    
    
    VAR data := {10, 20, 30}; AVGSTRICT(data) 	= 20
    AVGSTRICT({1, 2, 3})						= 2
    AVGSTRICT({1, NaN, 3})						= NaN

    ROUND

    ROUND(value1)    

    Vráti zaokrúhlenú hodnotu.

    Example 1: ROUND(2.01)   (Result is 2)
    Example 2: ROUND(2.49)   (Result is 2)
    Example 3: ROUND(2.5)   (Result is 3)
    Example 4: ROUND(2.99)   (Result is 3)

    ABS

    The ABS function returns the absolute value (i.e. the modulus) of any supplied number.

    ABS(number)

    Examples:

    ABS(100)  ...   100
    ABS(-100)   ...   100

    DEWPOINT

    DEWPOINT(temperature, relativeHumidity)
    

    Vráti teplotu rosného bodu vzhľadom na aktuálnu teplotu a relatívnu vlhkosť. Rosný bod sa vypočíta podľa tejto rovnice: http://bmcnoldy.rsmas.miami.edu/Humidity.html.

    Example 1: DEWPOINT(20, 0.50) (Result is ~9.26)
    Example 2: DEWPOINT(0, 1.00) (Result is 0)

    POWER

    The POWER function calculates a given number, raised to a supplied power.

    POWER(number, power)

    Examples:

    • POWER(2,3) … 2^3 = 8

    • POWER(10, -3) … 0,001

    • POWER(25, 0) … 1

    MOD

    The MOD function returns the remainder of a division between two supplied numbers.

    MOD(number, divisor)

    Arguments:

    • number - The number to be divided.

    • divisor - The value that the number argument is divided by.

    Examples:

    • MOD(6, 4)  … 2

    • MOD(6, 2.5) … 1

    CEIL

    The CEIL function rounds a supplied number away from zero, to the nearest multiple of a given number.

    CEIL(number, significance)

    Arguments:

    • number   - The number that is to be rounded.

    • significance (optional) - The multiple of significance that the supplied number should be rounded to. If the significance is not specified, then it is equal to 1.
      (This should generally have the same arithmetic sign (positive or negative) as the supplied number argument)

    Examples:

    • CEIL(22.25,0.1) … 22.3

    • CEIL(22.25,1) … 23

    • CEIL(22.25) … 23

    • CEIL(-22.25,-1) … -23

    • CEIL(-22.25,1) … -22

    • CEIL(-22.25) … -22

    • CEIL(-22.25,-5) … -25

    FLOOR

    The FLOOR function rounds a supplied number towards zero to the nearest multiple of a specified significance.

    FLOOR(number, significance)

    Arguments:

    • number - The number that is to be rounded.

    • significance (optional) -The multiple of significance that the supplied number is to be rounded to. If the significance is not specified, then it is equal to 1.
      (This should generally have the same arithmetic sign (positive or negative) as the supplied number argument)

    Examples:

    • FLOOR(22.25,0.1)… 22.2

    • FLOOR(22.25,1) … 22

    • FLOOR(22.25) … 22

    • FLOOR(-22.25,-1) … -22

    • FLOOR(-22.25,1) … -23

    • FLOOR(-22.25) … -23

    • FLOOR(-22.25,-5) … -20

    RAND

    The Rand function generates a random real number between 0 and 1.

    RAND()

    Examples:

    • RAND()

    RANDINT

    The RANDINT function generates a random integer between two supplied integers.

    RANDINT(bottom, top)

    Examples:

    • RANDINT(1,5)

    • RANDINT(-2,2)

    SIGN

    The SIGN function returns the arithmetic sign (+1, -1 or 0) of a supplied number. I.e. if the number is positive, the SIGN function returns +1, if the number is negative, the function returns -1 and if the number is 0 (zero), the function returns 0.

    SIGN(number)

    Examples:

    • SIGN(100) … 1

    • SIGN(0) … 0

    • SIGN(-100) … -1

    SQRT

    The SQRT function calculates the positive square root of a supplied number.

    SQRT(number)

    Examples:

    • SQRT(25) … 5

    LOG

    The LOG function calculates the logarithm of a given number, to a supplied base.

    LOG(number, base)

    Arguments:

    • number - The positive real number that you want to calculate the logarithm of.

    • base (optional) - An optional argument that specifies the base to which the logarithm should be calculated.
      If the argument is not specified, then the base argument uses the default value 10.

    Examples:

    • LOG(4,0.5) … -2

    • LOG(100) … 2

    LN

    The LN function calculates the natural logarithm of a given number.

    LN(number)

    where the number argument is the positive real number that you want to calculate the natural logarithm of.

    Examples:

    • LN(100) … 4,60517

    Bitové operácie

    GETBIT

    Returns a value of a bit in the specified position.

    GETBIT(number, bit_position)

    Arguments:

    • number - number to extract value of specific bit from

    • bit_position - position of bit, starting with 0, from right

    Examples:

    • GETBIT(2, 0) → first bit of number 2 (0b0010) is 0

    • GETBIT(4,2) → third bit of number 4 (0b0100) is 1

    GETBITS

    Returns value of specified number of bits in the specified position.

    GETBITS(number, start_bit, number_of_bits)

    Examples:

    • GETBITS(216, 3, 2) → number 216 = 0b1101 1000; value of 4th bit from the right is 1, 5th bit is 1, therefore result is 0b0011 = 3

    • GETBITS(0xFF, 0, 4) → number 0xFF = 255 = 0b1111 1111; value of first 4 bits from right is 0b1111 = 0xF = 15

    GETBYTE

    Returns a value of a byte in the specified number.

    GETBYTE( number, byte_position )

    Arguments:

    • number - number to extract value of specific byte from

    • byte_position - position of byte, starting from 0, from right

    Examples:

    GETBYTE(256, 0)  →  0001 0000 0000 →  0
    GETBYTE(256, 1)   →  0001 0000 0000  →  1
    GETBYTE(259, 0)   →  0001 0000 0011   →  3

    SETBYTE

    Assigns a new value to the specified byte in the provided number, and returns assigned value.

    SETBYTE( number, byte_position, new_value )

    Examples:

    SETBYTE(1, 0, 0)   →   0
    SETBYTE(256, 0, 255)   →   511
    SETBYTE(256, 1, 1)	  →   256
    SETBYTE(259, 1, 2)	  →    515

    SETBIT

    Assigns a new value to the specified bit in the provided number and returns a new number.

    SETBIT(number, bit_position, new_value)

    Arguments:

    • number - number to be modified

    • bit_position - position of bit, starting with 0, from right

    • new_value - 0 or 1 - value that is going to be set to specified bit

    Examples:

    • SETBIT(1, 1, 1) → 3

    • SETBIT(3, 1, 1) → 3

    • SETBIT(4, 2, 0) → 4

    • SETBIT(12, 1, 0) → 14

    SETBITS

    Assigns a new value to the specified bits in the provided number and returns a new number.

    SETBITS(number, start_bit, number_of_bits, new_value)

    Examples:

    • SETBITS(192, 4, 2, 3) → 240

    • SETBITS(192, 5, 2, 3) → 224

    <<   (LEFT BIT SHIFT)

    8 << 2   (32)

    Excel: BITLSHIFT(number, shift_amount)

    >> (RIGHT BIT SHIFT)

    32 >> 2   (8)

    Excel: BITRSHIFT(number, shift_amount)

    & (BITWISE AND)

    3 & 1   (1)

    Excel: BITAND(number1, number2)

    | (BITWISE OR)

    2 | 1 (3)

    Excel: BITOR(number1, number2)

    Text, String and Byte array

    LENGTH

    Returns length of an object or number of bytes. Object can be a number, boolean, string or Collection.

    LENGTH( object )

    Examples:

    LENGTH(“Hello World”)			(Result is 11)
    LENGTH(“40”)				(Result is 2)
    LENGTH(40)					(Result is 8)
    LENGTH(BYTECOLLECTION(“010203”)	(Result is 3)

    BYTECOLLECTION

    Creates a Collection<UInt8> from specified hexadecimal values

    BYTECOLLECTION( bytes )

    Examples:

    BYTECOLLECTION(“010203”) 				(Result is Collection<UInt8> {01, 02, 03})
    BYTECOLLECTION(“aa, be1-1,fe”) 			(Result is Collection<UInt8> {aa be 11 fe})

    INDEXOF

    Returns index of specified element in string or collection. Returns -1 if element cannot be found.

    INDEXOF( string/collection, element )

    Examples:

    INDEXOF("Hello", “H”)					(Result is 0)
    INDEXOF("Hello World", “Wor”)				(Result is 6)
    INDEXOF("Hello World", “Wor”)				(Result is 6)
    INDEXOF("Hello World", “or12”)				(Result is -1)
    INDEXOF(BYTECOLLECTION("ab cd ee ff 01 02"), 2)	(Result is 5)
    INDEXOF({1, 2, 3}, 3)						(Result is 2)

    COPY

    Copies specified string or collection (or part of them)

    COPY( string/collection, startIndex, length)

    Examples:

    COPY("Hello")					(Result is “Hello”)
    COPY("Hello World", 2)				(Result is “llo World”)
    COPY("Hello World", 2, 4)				(Result is “llo ”)
    COPY(BYTEARRAY("01020304")			(Result is byte array 01020304)
    COPY(BYTEARRAY("01020304", 2, 1)		(Result is byte array 03)

    REPLACE

    Returns a new string or collection, in which all occurrences of specified value are replaced with new value.

    REPLACE( string/collection, oldValue, newValue)

    Examples:

    REPLACE("Hello", “l”, “”)				(Result is “Heo”)
    REPLACE("Hello", “lo”, “22”)			(Result is “Hel22”)
    REPLACE(BYTECOLLECTION(“050607"), 5, 9)	(Result is Collection<UInt8>{09, 06, 07}

    SPLIT

    Splits string to substrings based on separator parameters.

    SPLIT( string, string )
    SPLIT( string, char )
    SPLIT( string, Collection<string> )
    SPLIT( string, Collection<char> )

    Examples:

    SPLIT("1;2;3;4", “;”)			(Result is Collection<String>{“1”, “2”, “3”, “4”})
    SPLIT("1;2;3.4", “2;”)		(Result is Collection<String>{“1;”, “3.4”})
    SPLIT("1;2;3.4", {“2”, “3.”)		(Result is Collection<String>{“1;”, “;”, “4”})

    COMPARE

    Compare 2 strings and returns an integer that indicates their relative position in the sort order.

    COMPARE( string, string, CompareOptions )

    Examples:

    COMPARE("abc", “abc”)						(Result is 0)
    COMPARE("abc", “ABC”)						(Result is 32)
    COMPARE("abc", “ABC”, CompareOptions.IgnoreCase)	(Result is 0)

    APPEND

    Append value to collection or string and returns new object with appended value.

    APPEND( string, string )
    APPEND( Collection, value )

    Examples:

    APPEND({1, 2}, 3)     (Result is Collection<Double>{1, 2, 3})
    APPEND("abc", “def”)  (Result is “abcdef”)

    INSERT

    Insert value to collection or string. Returns collection or string with inserted value.

    INSERT( collection, index, value )
    INSERT( string, index, value )

    Examples:

    INSERT(“Hello”, 5, “ World”)      (Result is “Hello World”)
    INSERT(“Hello”, 1, “i”)			  (Result is “Hiello”)
    INSERT({1, 2, 4}, 2, 3)			  (Result is Collection<Double>{1, 2, 3, 4})

    REMOVEAT

    Remove elements from collection or string based on element index and length. Returns collection or string without specified elements.

    REMOVEAT( collection, index, length )
    REMOVEAT( string, index, length )

    Examples:

    REMOVEAT(“Hello”, 1)			(Result is “Hllo”)
    REMOVEAT(“Hello”, 3, 2)			(Result is “Ho”)
    REMOVEAT({1, 2, 3, 4}, 2)			(Result is Collection<Double>{1, 2, 4})
    REMOVEAT({1, 2, 3, 4}, 2, 2)		(Result is Collection<Double>{1, 2})

    GETAT

    Get element value from collection or string based on provided index.

    GETAT( collection, index )
    GETAT( string, index )

    Examples:

    SETAT(“Hello”, 1, “a”)          (Result is “Hallo”)
    SETAT(“Hello”, 4, “o World”)    (Result is “Hello World”)
    SETAT({1, 2, 4}, 2, 3)          (Result is Collection<Double>{1, 2, 3})

    SETAT

    Set element value in collection or string at provided index.

    SETAT( collection, index, value )
    SETAT( string, index, value )

    Examples:

    INSERT(“Hello”, 5, “ World”)		(Result is “Hello World”)
    INSERT(“Hello”, 1, “i”)			(Result is “Hiello”)
    INSERT({1, 2, 4}, 2, 3)			(Result is Collection<Double>{1, 2, 3, 4})

    ENCODE

    Encodes specified string using on of the formats and returns the new string.

    ENCODE( string, format )

    Supported formats:

    • XML

    • Base64

    Examples:

    ENCODE("Hello", “xml”)				(Result is “Hello”)
    ENCODE("<Hello id=1>", “xml”)		(Result is “&lt;Hello id=1&gt;”)
    ENCODE("Hello", “base64”)			(Result is “SGVsbG8=”)

    DECODE

    Decodes specified string using one of the formats and returns the new string.

    DECODE( string, format )

    Supported formats:

    • XML

    • Base64

    Examples:

    DECODE("Hello", “xml”)				  (Result is “Hello”)
    DECODE("&lt;Hello id=1&gt;", “xml”)   (Result is “<Hello id=1>”)
    DECODE("SGVsbG8=", “base64”)		  (Result is “Hello”)

    EQUALS

    Compares two numbers with floating point. The numbers are considered to be equal if | n1 - n2 |< epsilon The default value of threshold (epsilon) is 0.005 and it is an optional parameter.

    EQUALS( number1, number2, epsilon=0.005 )

    Examples:

    EQUALS(1.33, 1.33)          1.0 (true)
    EQUALS(1.333, 1.3335)		1.0 (true)
    EQUALS(1.333, 1.338)		1.0 (false)
    EQUALS(1.333, 1.338, 0.01)	1.0 (true)
    EQUALS(NAN, NAN)		    1.0 (true)

    Sorting

    K dispozícii je viacero variantov ORDER:

    Vzostupne

    • ORDER, ORDERSTRICT
    • ORDERINDEX, ORDERINDEXSTRICT

      Zostupne

      • ORDERDESC, ORDERDESCSTRICT
      • ORDERINDEXDESC, ORDERINDEXDESCSTRICT

    ORDER

    Funkcia ORDER zoradí poskytnuté vstupné hodnoty vo vzostupnom poradí a vráti ich v novej kolekcii. Prijíma n hodnôt (až 100 argumentov) alebo jednu kolekciu. Hodnoty nemusia byť číselné, ale musia byť porovnateľné (napr. čísla, TIMESPAN, DATETIME, reťazce). Zmiešané typy (napr. čísla a reťazce) nie sú povolené. Hodnoty NaN a NULL sú ignorované a vylúčené z vrátenej kolekcie.

    ORDER( n1, n2, n3 , … )
    ORDER( collection )

    Examples:

    ORDER(3, 1, 2)				= {1, 2, 3}
    ORDER(1)					= {1}
    ORDER(3, NaN, 2, NaN)		= {2, 3}
    ORDER(NaN)					= {}
    ORDER('Z', 'a', 'X')				= {'X', 'Z', 'a'}
    ORDER(“str1”, “STR2”, “stR1”} 		= {"STR2", "stR1", "str1"}
    ORDER(“str1”, NULL, “STR2”, “stR1”} = {"STR2", "stR1", "str1"}
    
    ORDER(TIMESPAN(0,0,0,0,100), TIMESPAN(0,0,0,0,99)	= {TIMESPAN(0,0,0,0,99), TIMESPAN(0,0,0,0,100)}
    ORDER(NULL, TIMESPAN(0,0,0,0,99)					= {TIMESPAN(0,0,0,0,99)}

    ORDERINDEX

    Funkcia ORDERINDEX triedi poskytnuté vstupné hodnoty vo vzostupnom poradí, podobne ako funkcia ORDER. Namiesto vrátenia zoradených hodnôt však vráti kolekciu indexov označujúcich pozície pôvodných hodnôt v zoradenom poradí. Prijíma n hodnôt (až 100 argumentov) alebo jednu kolekciu. Hodnoty nemusia byť číselné, ale musia byť porovnateľné (napr. čísla, TIMESPAN, DATETIME, reťazce). Zmiešané typy (napr. čísla a reťazce) nie sú povolené. Hodnoty NaN a NULL sú ignorované a vylúčené z vrátenej kolekcie.

    ORDERINDEX( n1, n2, n3 , … )
    ORDERINDEX( collection )

    Examples:

    ORDERINDEX(3, 1, 2)				= {1, 2, 0}
    ORDERINDEX(1)					= {0}
    ORDERINDEX(3, NaN, 2, NaN)		= {2, 0}
    ORDERINDEX(NaN)					= {}
    ORDERINDEX('Z', 'a', 'X')				= {2, 0, 1}
    ORDERINDEX(“str1”, “STR2”, “stR1”} 		= {1, 2, 0}
    ORDERINDEX(“str1”, NULL, “STR2”, “stR1”} = {2, 3, 0}
    
    ORDERINDEX(TIMESPAN(0,0,0,0,100), TIMESPAN(0,0,0,0,99)	= {1, 0}
    ORDERINDEX(NULL, TIMESPAN(0,0,0,0,99)					= {1}

    ORDERSTRICT

    Funkcia ORDERSTRICT zoradí poskytnuté vstupné hodnoty vzostupne a vráti ich v novej kolekcii. Prijíma n hodnôt (až 100 argumentov) alebo jednu kolekciu. Hodnoty nemusia byť číselné, ale musia byť porovnateľné (napr. čísla, TIMESPAN, DATETIME, reťazce). Zmiešané typy (napr. čísla a reťazce) nie sú povolené. Hodnoty NaN a NULL sú zahrnuté a vo výsledku sú vždy zoradené ako prvé.

    ORDERSTRICT( n1, n2, n3 , … )
    ORDERSTRICT( collection )

    Examples:

    ORDERSTRICT(3, 1, 2)			= {1, 2, 3}
    ORDERSTRICT(1)					= {1}
    ORDERSTRICT(3, NaN, 2, NaN)		= {NaN, NaN, 2, 3}
    ORDERSTRICT(NaN)				= {NaN}
    ORDERSTRICT('Z', 'a', 'X')		= {'X', 'Z', 'a'}
    ORDERSTRICT(“str1”, “STR2”, “stR1”} 		= {"STR2", "stR1", "str1"}
    ORDERSTRICT(“str1”, NULL, “STR2”, “stR1”}	= {NULL, "STR2", "stR1", "str1"}
    
    ORDERSTRICT(TIMESPAN(0,0,0,0,100), TIMESPAN(0,0,0,0,99)	= {TIMESPAN(0,0,0,0,99), TIMESPAN(0,0,0,0,100)}
    ORDERSTRICT(NULL, TIMESPAN(0,0,0,0,99)					= {NULL, TIMESPAN(0,0,0,0,99)}

    ORDERINDEXSTRICT

    Funkcia ORDERINDEXSTRICT zoradí poskytnuté vstupné hodnoty vzostupne, podobne ako funkcia ORDERSTRICT. Namiesto vrátenia zoradených hodnôt však vráti kolekciu indexov označujúcich pozície pôvodných hodnôt v zoradenom poradí. Prijíma n hodnôt (až 100 argumentov) alebo jednu kolekciu. Hodnoty nemusia byť číselné, ale musia byť porovnateľné (napr. čísla, TIMESPAN, DATETIME, reťazce). Zmiešané typy (napr. čísla a reťazce) nie sú povolené. Hodnoty NaN a NULL sú zahrnuté a vo výsledku sú vždy zoradené ako prvé.

    ORDERINDEXSTRICT( n1, n2, n3 , … )
    ORDERINDEXSTRICT( collection )

    Examples:

    ORDERINDEXSTRICT(3, 1, 2)				= {1, 2, 0}
    ORDERINDEXSTRICT(1)						= {0}
    ORDERINDEXSTRICT(3, NaN, 2, NaN)		= {1, 3, 2, 0}
    ORDERINDEXSTRICT(NaN)					= {0}
    ORDERINDEXSTRICT('Z', 'a', 'X')			= {2, 0, 1}
    ORDERINDEXSTRICT(“str1”, “STR2”, “stR1”} 			= {1, 2, 0}
    ORDERINDEXSTRICT(“str1”, NULL, “STR2”, “stR1”} 		= {1, 2, 3, 0}
    
    ORDERINDEXSTRICT(TIMESPAN(0,0,0,0,100), TIMESPAN(0,0,0,0,99)	= {1, 0}
    ORDERINDEXSTRICT(NULL, TIMESPAN(0,0,0,0,99)						= {0, 1}

    ORDERDESC

    Funkcia ORDERDESC zoradí poskytnuté vstupné hodnoty v zostupnom poradí a vráti ich v novej kolekcii. Prijíma n hodnôt (až 100 argumentov) alebo jednu kolekciu. Hodnoty nemusia byť číselné, ale musia byť porovnateľné (napr. čísla, TIMESPAN, DATETIME, reťazce). Zmiešané typy (napr. čísla a reťazce) nie sú povolené. Hodnoty NaN a NULL sú ignorované a vylúčené z vrátenej kolekcie.

    ORDERDESC( n1, n2, n3 , … )
    ORDERDESC( collection )

    Examples:

    ORDERDESC(3, 1, 2)					= {3, 2, 1}
    ORDERDESC(1)						= {1}
    ORDERDESC(3, NaN, 2, NaN)			= {3, 2}
    ORDERDESC(NaN)						= {}
    ORDERDESC('Z', 'a', 'X')			= {'a', 'Z', 'X'}
    ORDERDESC(“str1”, “STR2”, “stR1”} 	= {"str1", "stR1", "STR2"}
    ORDERDESC(“str1”, NULL, “STR2”, “stR1”} 	= {"str1", "stR1", "STR2"}
    
    ORDERDESC(TIMESPAN(0,0,0,0,100), TIMESPAN(0,0,0,0,99)	= {TIMESPAN(0,0,0,0,100), TIMESPAN(0,0,0,0,99)}
    ORDERDESC(NULL, TIMESPAN(0,0,0,0,99)					= {TIMESPAN(0,0,0,0,99)}

    ORDERINDEXDESC

    Funkcia ORDERINDEXDESC zoraďuje poskytnuté vstupné hodnoty v zostupnom poradí, podobne ako funkcia ORDERDESC. Namiesto vrátenia zoradených hodnôt však vráti kolekciu indexov označujúcich pozície pôvodných hodnôt v zoradenom poradí. Prijíma n hodnôt (až 100 argumentov) alebo jednu kolekciu. Hodnoty nemusia byť číselné, ale musia byť porovnateľné (napr. čísla, TIMESPAN, DATETIME, reťazce). Zmiešané typy (napr. čísla a reťazce) nie sú povolené. Hodnoty NaN a NULL sú ignorované a vylúčené z vrátenej kolekcie.

    ORDERINDEXDESC( n1, n2, n3 , … )
    ORDERINDEXDESC( collection )

    Examples:

    ORDERINDEXDESC(3, 1, 2)				= {0, 2, 1}
    ORDERINDEXDESC(1)					= {0}
    ORDERINDEXDESC(3, NaN, 2)			= {0, 2}
    ORDERINDEXDESC(NaN)					= {}
    ORDERINDEXDESC('Z', 'a', 'X')					= {1, 0, 2}
    ORDERINDEXDESC(“str1”, “STR2”, “stR1”} 			= {0, 2, 1}
    ORDERINDEXDESC(“str1”, NULL, “STR2”, “stR1”} 	= {0, 3, 2}
    
    ORDERINDEXDESC(TIMESPAN(0,0,0,0,100), TIMESPAN(0,0,0,0,99)	= {0, 1}
    ORDERINDEXDESC(NULL, TIMESPAN(0,0,0,0,99)					= {1}

    ORDERDESCSTRICT

    Funkcia ORDERDESCSTRICT zoradí poskytnuté vstupné hodnoty v zostupnom poradí a vráti ich v novej kolekcii. Prijíma n hodnôt (až 100 argumentov) alebo jednu kolekciu. Hodnoty nemusia byť číselné, ale musia byť porovnateľné (napr. čísla, TIMESPAN, DATETIME, reťazce). Zmiešané typy (napr. čísla a reťazce) nie sú povolené. Hodnoty NaN a NULL sú zahrnuté a vo výsledku sú vždy zoradené ako prvé.

    ORDERDESCSTRICT( n1, n2, n3 , … )
    ORDERDESCSTRICT( collection )

    Examples:

    ORDERDESCSTRICT(3, 1, 2)			= {3, 2, 1}
    ORDERDESCSTRICT(1)					= {1}
    ORDERDESCSTRICT(3, NaN, 2, NaN		= {NaN, NaN, 3, 2}
    ORDERDESCSTRICT(NaN)				= {NaN}
    ORDERDESCSTRICT('Z', 'a', 'X')					= {'a', 'Z', 'X'}
    ORDERDESCSTRICT(“str1”, “STR2”, “stR1”} 		= {"str1", "stR1", "STR2"}
    ORDERDESCSTRICT(“str1”, NULL, “STR2”, “stR1”} 	= {NULL, "str1", "stR1", "STR2"}
    
    ORDERDESCSTRICT(TIMESPAN(0,0,0,0,100), TIMESPAN(0,0,0,0,99)	= {TIMESPAN(0,0,0,0,100), TIMESPAN(0,0,0,0,99)}
    ORDERDESCSTRICT(NULL, TIMESPAN(0,0,0,0,99)					= {NULL, TIMESPAN(0,0,0,0,99)}

    ORDERINDEXDESCSTRICT

    Funkcia ORDERINDEXDESCSTRICT zoradí zadané vstupné hodnoty zostupne, podobne ako funkcia ORDERDESC. Namiesto zoradených hodnôt však vracia kolekciu indexov označujúcich pozície pôvodných hodnôt v zoradenom poradí. Funkcia akceptuje n hodnôt (až 100 argumentov) alebo jednu kolekciu. Hodnoty nemusia byť číselné, ale musia byť porovnateľné (napr. čísla, TIMESPAN, DATETIME, reťazce). Zmiešané typy (napr. čísla a reťazce) nie sú povolené. Hodnoty NaN a NULL sú zahrnuté a vo výsledku sú vždy zoradené ako prvé.

    ORDERINDEXDESCSTRICT( n1, n2, n3 , … )
    ORDERINDEXDESCSTRICT( collection )

    Examples:

    ORDERINDEXDESCSTRICT(3, 1, 2)				= {0, 2, 1}
    ORDERINDEXDESCSTRICT(1)						= {0}
    ORDERINDEXDESCSTRICT(3, NaN, 2, NaN)		= {1, 3, 0, 2}
    ORDERINDEXDESCSTRICT(NaN)					= {0}
    ORDERINDEXDESCSTRICT('Z', 'a', 'X')			= {1, 0, 2}
    ORDERINDEXDESCSTRICT(“str1”, “STR2”, “stR1”}		= {0, 2, 1}
    ORDERINDEXDESCSTRICT(“str1”, NULL, “STR2”, “stR1”} 	= {1, 0, 3, 2}
    
    ORDERINDEXDESCSTRICT(TIMESPAN(0,0,0,0,100), TIMESPAN(0,0,0,0,99)	= {0, 1}
    ORDERINDEXDESCSTRICT(NULL, TIMESPAN(0,0,0,0,99)						= {0, 1}

    Date and time

    DATETIME

    Vytvorí objekt DateTime.

    Vlastnosť DateTime.Ticks je počet milisekúnd od 1.1.0001 00:00:00.000.

    DateTime má vlastnosti: TICK, YEAR, MONTH, DAY, DAYOFWEEK, DAYOFYEAR, HOUR, MINUTE, SECOND, MILLISECOND, KIND, UTCDATETIME, LOCALDATETIME, UNIXTIME

    DATETIME( ticks, DateTimeKind )
    DATETIME( string, format )
    DATETIME( string, DateTimeKind )
    DATETIME( year, month, day, hour, minute, second, millisecond, DateTimeKind  )

    Examples:

    VAR date:= DATETIME(2014, 12, 8, 23, 54, 12, 456);
    VAR date:= DATETIME(2014, 12, 8, 23, 54, 12, 456, DateTimeKind.Local);
    VAR date:= DATETIME(2014, 12, 8, 23, 54, 12, 456, DateTimeKind.Utc);
    VAR date:= DATETIME("13:36");
    VAR date:= DATETIME("2022-08-03T07:39:03.688133+05:00");
    VAR date:= DATETIME("03.01 2008 10:00"); 
    VAR date:= DATETIME("mar.01 2008 10:00");
    VAR date:= DATETIME("03.01 2008 10:00", "dd.MM yyyy hh:mm");
    VAR date:= DATETIME(518832000);
    VAR date:= DATETIME(518832000, DateTimeKind.Utc);
    VAR date := NOW(); date.YEAR := 1999;
    DATETIME date; date.UNIXTIME := 123456;

    NOW

    Vráti objekt DateTime, ktorý je nastavený na aktuálny dátum a čas v miestnom časovom pásme.

    NOW()

    Examples:

    VAR now := NOW();

    TIMESPAN

    Funkcia TIMESPAN vytvorí premennú, ktorá predstavuje trvanie času zadaného v dňoch, hodinách, minútach, sekundách a milisekundách.

    TIMESPAN má vlastnosti na priamy prístup ku každej zložke časového úseku: DAYS, HOURS, MINUTES, SECONDS, MILLISECONDS.

    TIMESPAN má vlastnosti na prístup k celkovej hodnote času v konkrétnych jednotkách (vrátane zlomkových hodnôt): TOTALDAYS, TOTALHOURS, TOTALMINUTES, TOTALSECONDS, TOTALMILLISECONDS

    TIMESPAN( days, hours, minutes, seconds, milliseconds )

    Examples:

    VAR t := TimeSpan(1, 2, 3, 4, 0);
    	t.TOTALSECONDS			
    
    Result ... 93784

    LOCALTIMEZONE

    Vráti miestnu časovú zónu ako počet milisekúnd od času UTC.

    LOCALTIMEZONE()

    Examples:

    VAR timezoneDiff := LOCALTIMEZONE();

    DATETIMEADD

    Pridá zadaný počet rokov, mesiacov, dní, hodín, minút, sekúnd, milisekúnd k existujúcemu DateTime a vráti nový DateTime.

    DATETIMEADD(datetime, years, months, days, hours, minutes, seconds, milliseconds)

    Examples:

    VAR dt := NOW(); VAR yearBefore := DATETIMEADD(dt, -1);

    Data type conversions

    TODOUBLE

    Prevedie reťazec na číslo. Pri chybe vráti NaN.

    TODOUBLE( text )

    Examples:

    TODOUBLE(“232”) ... 232)
    TODOUBLE(“-192.332”)  ...  -192.332
    TODOUBLE(“some text”)  ...  NaN

    TOSTRING

    Vráti hodnotu reťazca zadanej hodnoty alebo kolekciu podľa zadaného kódovania. Kódovanie je voliteľné (predvolene sa používa iso-8859-1).

    TOSTRING(value, encoding)

    Examples:

    TOSTRING(192, “X”)  …  Result = “C0”
    TOSTRING(192, “X4”)  …  Result = “00C0”
    TOSTRING(192, “F4”)  …  Result = “123.3400”
    TOSTRING(192, “F0”)  …  Result = “123”
    TOSTRING(BYTECOLLECTION("48656c6c6f"))			(Result is “Hello”)
    TOSTRING(BYTECOLLECTION(\"48656c6c6f\"), “iso-8859-1”)	(Result is “Hello”)
    TOSTRING(192, “X4”)							(Result is “00C0”)

    TOBCD

    Converts the provided number to the binary-coded decimal (BCD) format. The scheme of encoding is BCD-8421.

    TOBCD(number)

    Examples:

    TOBCD(1)  ...  1
    TOBCD(9)  ...  9
    TOBCD(10)  ...  16

    FROMBCD

    Decodes the provided number, that is encoded in binary-coded decimal (BCD) format. The scheme of encoding is BCD-8421.

    FROMBCD(number)

    Examples:

    FROMBCD(16)  ...  10
    FROMBCD(32)  ...  20

    TOBYTEARRAY

    Converts string to byte array according to the specified encoding. Encoding is optional (iso-8859-1 is used by default).

    TOBYTEARRAY( string, encoding )

    Examples:

    TOBYTEARRAY("Hello")			(Result is byte array 48656c6c6f)

    RGBTOHSV

    Converts RGB color definition; returns color in Hue / Saturation / Brightness format.

    RGBTOHSV( r, g, b )      (r, g, b ... 0 - 0xFF)

    Example:

    VAR HSVColor := RGBTOHSV( r, g, b );
    VAR saturation := HSVColor.Saturation;   (Saturation ... 0 - 1)
    VAR hue := HSVColor.Hue;                 (Hue ... 0 - 360)
    VAR value := HSVColor.Value;             (Value ... 0 - 1)

    HSVTORGB

    Converts color defined by Hue / Saturation / Brightness; returns color in RGB format

    HSVTORGB( hue, saturation, value )

    Example:

    VAR color := HSVTORGB( hue, saturation, 1)
    VAR red := color.red;                   (red ... 0 - 0xFF)
    VAR green := color.green;               (green ... 0 - 0xFF)
    VAR blue := color.blue;                 (blue ... 0 - 0xFF)

    Parsing functions

    PARSETEXT

    Returns part of input text, based on left and right search patterns

    PARSETEXT( input, left_pattern, right_pattern)

    Examples:

    PARSETEXT(“Lorem ipsum dolor sit amet”, “ipsum”, “amet”) (Result is “dolor sit”)
    PARSETEXT(“<temp>12.2</temp>”, “<temp>”, “</temp”) (Result is 12.2)
    PARSETEXT(“<temp>12.2</temp>”, “<temp>”) (Result is 12.2)
    PARSETEXT(“status:ok,error:none”, “status:”) (Result is “ok”)
    PARSETEXT(“Lorem ipsum dolor sit amet”, “ipsum”) (Result is “dolor”)
    PARSETEXT(“Lorem ipsum dolor sit amet”, “ipsum…sit”) (Result is “amet”)
    PARSETEXT(“Lorem ipsum dolor sit amet consectetur adipiscing”, “ipsum…sit”, “adipiscing”) (Result is “amet consectetur”)

    PARSEJSON

    Returns value of element from json formatted string. Element is specified with json path.

    PARSEJSON( json_string, json_path, ignore_error)

    Examples:

    With json = { "firstName": "John",
      "lastName" : "doe",
      "age" : 26,
      "address"  : {
        "streetAddress": "naist street",
        "city"         : "Nara",
        "postalCode"   : "630-0192"
      }
    }
    
    PARSEJSON(json, “firstName”)			(Result is “John”)
    PARSEJSON(json, “address.city”)		(Result is “Nara”)
    PARSEJSON(json, “address.country”)		(error)
    PARSEJSON(json, “address.country”, 0)		(error)
    PARSEJSON(json, “address.city”, 1)		(Result is null)

    PARSEXML

    Returns value of element from xml string. Element is specified with xml path.

    PARSEXML( xml_string, xml_path)

    Examples:

    With xml= <?xml version="1.0"?>
    <catalog>
    	<book id="bk101">
    		<author>Gambardella, Matthew</author>
    		<title>XML Developer's Guide</title>
    		<genre>Computer</genre>
    		<price>44.95</price>
    		<publish_date>2000-10-01</publish_date>
    		<description>An in-depth look at creating...</description>
    	</book>
    	<book id="bk102">
    		<author>Ralls, Kim</author>
    		<title>Midnight Rain</title>
    		<genre>Fantasy</genre>
    		<price>5.95</price>
    		<publish_date>2000-12-16</publish_date>
    		<description>A former architect battles…</description>
    	</book>
    </catalog>
    
    PARSEXML(xml, “//catalog/book[1]/price”) (Result is 44.95)
    PARSEXML(xml, “//book[2]/title”) (Result is “Midnight Rain”)
    PARSEXML(xml, “//book[1]/@id”) (Result is “bk101”)
    PARSEXML(xml, “//catalog/magazine[1]/price”) (Result is null)

    If xml contains namespaces, you have to fully specify element names with namespace, eg. PARSEXML(xml, "//DIDL-Lite:container[dc:title='My Playlist’']/DIDL-Lite:res");

    Packet parser

    SENDHTTPREQUEST

    SENDDATA

    MQTTPUBLISH

    FTPDOWNLOAD

    FTPUPLOAD

    COMPLETESERVICEATTRIBUTE

    COMPLETESERVICEACTION

    Modbus