Evaluations - AppDaddy-Software-Solutions-Inc/framework-markup-language GitHub Wiki

Overview

Evaluations are simply a string of one or comma ";" separated events or widget *method calls. Evaluations can contain widget bindings as parameters.

Evaluations always start with the equals "=" when specfied as a widget attribute. Widget events are always treated as *evaluations and can omit the equals prefix.

All events or widget *method calls have a return value of *boolean. When an evaluation string contains more than one event or method call, each is evaluated in turn. If a evaluation returns false, the evaluation terminates immediately and returns.

Operators

Name Type Description
+ addition Adds to operands.
- subtraction Subtracts to operands.
* multiplication Multiplies to operands.
/ division Divides two operands.
! Logical Negotiation Returns the reversed meaning of operand.
?? Null Aware left ?? right returns right if left is null.
|| Logical OR Returns true if either or both operands are true, returns false otherwise.
&& Logical AND Returns true if both operands are true, returns false otherwise.
| Binary OR Preforms bitwise OR on two operands.
^ Binary XOR Preforms bitwise XOR on two operands.
& Binary AND Compares each bit of the first operand to the corresponding bit of the second operand. If both bits are 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.
== Equal To Returns true if left equals right.
!= Not Equal To Returns true if left does not equal right.
<= Less Than or Equal To Returns true if left is less than or equal to right.
>= Greater Than or Equal To Returns true if left is greater than or equal to right.
< Less Than Returns true if left is less than right.
> Greater Than Returns true if left is greater than right.
<< Left Shift Shifts a binary representation to b bits to left and inserting 0 from right.
>> Right Shift Shifts a binary representation to b bits to left and inserting 0 from left.
% Modulus Gives the remainder of two operands.

Functions

Logical

case ( $${\color{blue}dynamic}$$ value, [ $${\color{blue}dynamic}$$ case1, $${\color{blue}dynamic}$$ return1, $${\color{blue}dynamic}$$ case2, $${\color{blue}dynamic}$$ return2, ... , $${\color{blue}dynamic}$$ case10, $${\color{blue}dynamic}$$ return10 ] ) → $${\color{blue}dynamic}$$ Attempts to match the binding value to a case value and returns a value from that case
if ( $${\color{blue}dynamic}$$ value, $${\color{blue}dynamic}$$ value2, $${\color{blue}dynamic}$$ value3 ) → $${\color{blue}dynamic}$$ If value is true return value2, otherwise value3
isNull ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}bool}$$ If value is null return true, otherwise false
isPhone ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}bool}$$ Converts value to a string and returns true if value is formatted in a valid phone number format, otherwise false
isCard ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}bool}$$ Converts value to a string and returns true if value is formatted in a valid credit card format, otherwise false
isEmail ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}bool}$$ Converts value to a string and returns true if value is formatted in a valid email address format, otherwise false
noe ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}bool}$$ If value is null or whitespace return true, otherwise false
nvl ( $${\color{blue}dynamic}$$ value, $${\color{blue}dynamic}$$ default ) → $${\color{blue}dynamic}$$ If value is null return default, otherwise value

DateTime

addTime ( $${\color{blue}string}$$ amount, $${\color{blue}string}$$ date, ) → $${\color{blue}int}$$ Converts date to a DateTime, adds the amount expressed in plain language time values (ie: 500ms, 1 year, 3 weeks), and returns the date result as a string.
isBefore ( $${\color{blue}dynamic}$$ date1, $${\color{blue}dynamic}$$ date2, ) → $${\color{blue}int}$$ Converts date1 and date2 to DateTime and returns true if date1 is earlier than date2.
isAfter ( $${\color{blue}dynamic}$$ date1, $${\color{blue}dynamic}$$ date2, ) → $${\color{blue}int}$$ Converts date1 and date2 to DateTime and returns true if date1 is later than date2.
subtractTime ( $${\color{blue}string}$$ amount, $${\color{blue}string}$$ date, ) → $${\color{blue}int}$$ Converts date to a DateTime, subtracts the amount expressed in plain language time values (ie: 500ms, 1 year, 3 weeks), and returns the date result as a string.
timeBetween ( $${\color{blue}string}$$ date1, $${\color{blue}string}$$ date2, ) → $${\color{blue}int}$$ Converts date1 and date2 to DateTime and returns a time between expressed in plain language time values (ie: 500ms, 1 year, 3 weeks).
toDate ( $${\color{blue}dynamic}$$ value, [ $${\color{blue}string}$$ inputFormat, $${\color{blue}string}$$ outputFormat ] ) → $${\color{blue}string}$$ Converts value to DateTime using the specified inputFormat and returns the result using the specified outputFormat
toEpoch ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}int}$$ Converts value to DateTime and returns the number of milliseconds since 1970-01-01T00:00:00Z (UTC). Commonly referred to as Unix time.

Boolean

isBool ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}bool}$$ If value is a boolean (true, false, 'true', 'false', '1', '0', 'yes', 'no') return true, otherwise false.
toBool ( value ) → $${\color{blue}bool}$$ Converts value to boolean. String values "true", "yes" and "1" return true, "false", "no" and "0" return false, othersie null.

Numeric

abs ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}int}$$ Converts value to numeric and returns its absolute value
acos ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}double}$$ Converts value to numeric and returns its arc cosine
asin ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}double}$$ Converts value to numeric and returns its arc sine
atan ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}double}$$ Converts value to numeric and returns its arc tangent
ceil ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}int}$$ Converts value to numeric and returns the largest integer greater than or equal to the value.
cos ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}double}$$ Converts value to numeric and returns its cosine
floor ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}int}$$ Converts value to numeric and returns the largest integer less than or equal to the value.
isNumeric ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}bool}$$ If value is numeric return true, otherwise false.
mod ( $${\color{blue}dynamic}$$ value, $${\color{blue}int}$$ divisor ) → $${\color{blue}int}$$ Converts value to numeric and returns the remainder of the value divided by the *divisor*
number ( $${\color{blue}dynamic}$$ value, $${\color{blue}bool}$$ currency, $${\color{blue}bool}$$ compact, [ $${\color{blue}bool}$$ semicompact ] ) → $${\color{blue}string}$$ Converts value to numeric.
  • If currency is true it will add a dollar sign and keep 2 digits after the decimal
  • If compact is true it will suffux a number with a letter for example: k for thousand or M for million, creating a shortened
  • number representation
  • If semicompact is true it will write the full word as the suffix, example: 1000 = 1 thousand
  • pi → $${\color{blue}double}$$ The value pi.
    round ( $${\color{blue}dynamic}$$ value, $${\color{blue}int}$$ precision, $${\color{blue}bool}$$ pad ) → $${\color{blue}int}$$ Converts value to numeric and returns value rounded to the nearest digit before(-) or after (+) the decimal, and adds padding of trailing 0's.
    sin ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}double}$$ Converts value to numeric and returns its sine
    tan ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}double}$$ Converts value to numeric and returns its tangent
    toDouble ( $${\color{blue}dynamic}$$ value ) → $${\color{blue} int}$$ Converts value to a double
    toInt ( $${\color{blue}dynamic}$$ value ) → $${\color{blue} int}$$ Converts value to an integer
    toNum ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}numeric}$$ Converts value to numeric
    truncate ( $${\color{blue}dynamic}$$ value, precision, pad ) → $${\color{blue}double}$$ Truncates the value to the nearest digit before(-) or after (+) the decimal, and adds padding of trailing 0's.

    String

    contains ( $${\color{blue}dynamic}$$ value, $${\color{blue}string}$$ pattern ) → $${\color{blue}bool}$$ Converts value to string and returns true if the result contains the pattern, otherwise false.
    decode ( $${\color{blue}string}$$ value ) → $${\color{blue}string}$$ Decodes value from BASE64 to UTF8
    decrypt ( $${\color{blue}string}$$ value, $${\color{blue}string}$$ key ) → $${\color{blue}string}$$ Decrypts value using the supplied cyptopgraphy key
    encode ( $${\color{blue}string}$$ value ) → $${\color{blue}string}$$ Encodes value from UTF8 to BASE64
    encrypt ( $${\color{blue}string}$$ value, $${\color{blue}string}$$ key ) → $${\color{blue}string}$$ Encrypts value using the supplied cyptopgraphy key
    endsWith ( $${\color{blue}dynamic}$$ value, $${\color{blue}string}$$ pattern ) → $${\color{blue}bool}$$ Converts value to string and returns true if the result ends with the pattern, otherwise false.
    hash ( $${\color{blue}dynamic}$$ value, [ $${\color{blue}string}$$ key ] ) → $${\color{blue}bool}$$ Converts value to string and returns the hashed value using the supplied hash key. If key is not supplied, the hask key from config.xml is used.
    join ( $${\color{blue}dynamic}$$ value, [ $${\color{blue}dynamic}$$ value1, $${\color{blue}dynamic}$$ value2, ... , $${\color{blue}dynamic}$$ value9) ] ) → $${\color{blue}string}$$ Converts value to string and appends value1 through value9
    length ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}int}$$ If value is a list returns the number of entries in the list, otherwise converts value to string and returns its length
    lpad ( $${\color{blue}dynamic}$$ value, $${\color{blue}int}$$ length, [ $${\color{blue}int}$$ character := " " ] ) → $${\color{blue}int}$$ Converts value to string and left pads it to the specified length using the specified character.
    replace ( $${\color{blue}dynamic}$$ value, $${\color{blue}string}$$ pattern, $${\color{blue}string}$$ value2 ) → $${\color{blue}string}$$ Converts value to string and returns the result with all matching pattern's replaced with value2
    rpad ( $${\color{blue}dynamic}$$ value, $${\color{blue}int}$$ length, [ $${\color{blue}int}$$ character := " " ] ) → $${\color{blue}int}$$ Converts value to string and right pads it to the specified length using the specified character.
    split( $${\color{blue}dynamic}$$ value, $${\color{blue}string}$$ character, [ $${\color{blue}int}$$ index ] ) → $${\color{blue}dynamic}$$ Converts value to string, splits the result using the specified character. If index is not null, returns the value at the specified position in the resulting list, otherwise returns the list.
    startsWith ( $${\color{blue}dynamic}$$ value, $${\color{blue}string}$$ pattern ) → $${\color{blue}bool}$$ Converts value to string and returns true if the result starts with the pattern, otherwise false.
    substring ( $${\color{blue}dynamic}$$ value, $${\color{blue}int}$$ fromIndex, $${\color{blue}int}$$ toIndex ) → $${\color{blue}string}$$ Converts value to string and returns the trimmed substring from index fromIndex to toIndex. If toIndex is not suppied, it is assumed to be to the end of the the string.
    toHex ( $${\color{blue}dynamic}$$ value, [ $${\color{blue}bool}$$ add0xprefix := false ] ) → $${\color{blue}string}$$ Converts value to int and then to its base16 hexidecimal equivalent. If add0xprefix is true the result is prefixed with '0x'. The result is returned as a string
    toJson ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}string}$$ Converts value to string and parses the result as json. If valid, the formatted result is returned, otherwise null.
    toLower ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}string}$$ Converts value to string and returns the string with all characters converted to lower case.
    toStr ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}string}$$ Converts value to string
    toUpper ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}string}$$ Converts value to string and returns the string with all characters converted to upper case.
    toXml ( $${\color{blue}dynamic}$$ value ) → $${\color{blue}string}$$ Converts value to string and parses the result as xml. If valid, the formatted result is returned, otherwise null.

    List

    elementAt ( $${\color{blue}list}$$ list, $${\color{blue}int}$$ index ) → $${\color{blue}dynamic}$$ Returns the element in the list at the specified at index
    indexOf ( $${\color{blue}list}$$ object, $${\color{blue}int}$$ list ) → $${\color{blue}int}$$ Returns the index in the list of the specified object. Null if not in the list.
    toList ( $${\color{blue}list}$$ list, [ $${\color{blue}string}$$ where ] ) → $${\color{blue}list}$$ Returns the elements in the list matching the where clause.

    Note: The where clause need's to be passed as a literal (un-translated) string. This can be achieved using a <BLOB/> variable in place of the actual where and instead paasing a binding to the variable in its place.
    first ( $${\color{blue}list}$$ list, [ $${\color{blue}string}$$ where ] ) → $${\color{blue}list}$$ Returns the first element in the list matching the where clause.

    Note: The where clause need's to be passed as a literal (un-translated) string. This can be achieved using a <BLOB/> variable in place of the actual where and instead paasing a binding to the variable in its place.
    last ( $${\color{blue}list}$$ list, [ $${\color{blue}string}$$ where ] ) → $${\color{blue}list}$$ Returns the last element in the list matching the where clause.

    Note: The where clause need's to be passed as a literal (un-translated) string. This can be achieved using a <BLOB/> variable in place of the actual where and instead paasing a binding to the variable in its place.
    sum ( $${\color{blue}list}$$ list, $${\color{blue}string}$$ field, [ $${\color{blue}string}$$ where ] ) → $${\color{blue}double}$$ Returns the sum of all elements in the list for the specified field matching the where clause.

    Note: The where clause need's to be passed as a literal (un-translated) string. This can be achieved using a <BLOB/> variable in place of the actual where and instead paasing a binding to the variable in its place.
    average/avg ( $${\color{blue}list}$$ list, $${\color{blue}string}$$ field, [ $${\color{blue}string}$$ where ] ) → $${\color{blue}double}$$ Returns the average of all elements in the list for the specified field matching the where clause.

    Note: The where clause need's to be passed as a literal (un-translated) string. This can be achieved using a <BLOB/> variable in place of the actual where and instead paasing a binding to the variable in its place.
    count/cnt ( $${\color{blue}list}$$ list, $${\color{blue}string}$$ field, [ $${\color{blue}string}$$ where ] ) → $${\color{blue}int}$$ Returns the count of all elements in the list for the specified field matching the where clause.

    Note: The where clause need's to be passed as a literal (un-translated) string. This can be achieved using a <BLOB/> variable in place of the actual where and instead paasing a binding to the variable in its place.
    minimum/min ( $${\color{blue}list}$$ list, $${\color{blue}string}$$ field, $${\color{blue}string}$$ where ) → $${\color{blue}double}$$ Returns the minimum of all elements in the list for the specified field matching the where clause.

    Note: The where clause need's to be passed as a literal (un-translated) string. This can be achieved using a <BLOB/> variable in place of the actual where and instead paasing a binding to the variable in its place.
    maximum/max ( $${\color{blue}list}$$ list, $${\color{blue}string}$$ field, $${\color{blue}string}$$ where ) → $${\color{blue}double}$$ Returns the maximum of all elements in the list for the specified field matching the where clause.

    Note: The where clause need's to be passed as a literal (un-translated) string. This can be achieved using a <BLOB/> variable in place of the actual where and instead paasing a binding to the variable in its place.
    read ( $${\color{blue}list}$$ list, $${\color{blue}string}$$ field ) → $${\color{blue}dynamic}$$ Reads the value of the first element in the list for the specified field.
    write ( $${\color{blue}list}$$ list, $${\color{blue}string}$$ field $${\color{blue}string}$$ value ) → $${\color{blue}dynamic}$$ Writes the value to the first element in the list for the specified field.

    Note: This does not automatically cause the databroker to notify its listeners. To do this use the databroker's notify() method.

    GeoSpacial

    distance ( $${\color{blue}string}$$ latitude1, $${\color{blue}string}$$ longitude1, $${\color{blue}string}$$ latitude2, $${\color{blue}string}$$ longitude2, ) → $${\color{blue}meters}$$ Calculates the disance in between point(latitude1,longitude1) and point(latitude2,longitude2)

    Other

    $${\color{blue}pkg.method}$$ ( [ $${\color{blue}dynamic}$$ parameter1, $${\color{blue}dynamic}$$ parameter2, ... , $${\color{blue}dynamic}$$ parameterN, ] ) Calls the plugin method `` in [``](./Package) and returns the dynamic result.

    Examples

    (fig. a)

    An eval returning a color string based on a variables value.

    <VAR id="isred" value="true"/>
    <TEXT color="={isred}?red:green" label="Am I Red?"/>
    (fig. b)

    An eval() setting a TABLEROW widgets color to alternating based on the modulus of the index.

    <TABLEROW id="datarow" color="=mod({datarow.index}, 2)==0?#0AFF0000:#0A0000FF"/>
    (fig. c)

    Round and return the value 123.40.

    <TEXT value="=round(123.4, 2, true))" />
    (fig. d)

    An eval setting the texts color to green using contains() if the input variable contains 'He'.

    <FML>
    	<VAR id="inputvalue" value="Hello"/>
    	<TEXT color="=contains({inputvalue}, He)?green:red" label="Succeeded?"/>
    </FML>
    (fig. e)

    An eval with a substring() returning the word 'There'.

    <FML>
    	<VAR id="inputvalue" value="HelloThereHi"/>
    	<TEXT color="black" label="=substring('{inputvalue}', 5, 10)"/>
    </FML>

    Other Widgets You May Find Useful:

    ⚠️ **GitHub.com Fallback** ⚠️