Functions in Device Automation

Device Automation language now contains functions that you can use. The implementation of the functions is similar to website Robot Language. See Functions for more information. The following functions are available.

Numeric
  • abs(Integer): Integer
  • abs(Number): Number
  • ceil(Number): Integer
  • floor(Number): Integer
  • round(Number): Integer
  • max(Integer, Integer): Integer
  • max(Number, Number): Number
  • min(Integer, Integer): Integer
  • min(Number, Number): Number
  • random(): Number - greater than or equal to 0.0 and less than 1.0
  • random(Integer, Integer): Integer - greater than or equal to arg(0) and less than or equal to arg(1)
Text
  • length(Text): Integer
  • substring(Text, Integer): Text
  • substring(Text, Integer, Integer): Text
  • indexOf(Text, Text): Integer
  • contains(Text, text): Boolean
  • trim(Text): Text
  • capitalize(Text): Text
  • startsWith(Text, text): Boolean
  • endsWith(Text, text): Boolean
  • toLowerCase(Text): Text
  • toUpperCase(Text): Text

The following functions are created for Device Automation and can only be used in the Device Automation step. They convert one type of value to another type.

Function

Description

Notes

integer(): Integer

Converts a number to an Integer if the number can be represented as an integer without loss of precision, such as 2.0.int() = 2. If this is not possible, an exception is thrown.

The int function behaves as follows:

If the decimal number is an integer, it is converted to an integer representing the same number. For example 2.0 is converted to 2. If the number is not an integer, such as 10.9, the conversion fails and throws an exception. This is similar to what happens if you try to convert a text to a number if the text is not a number.

int(Text): Integer

Parses text and converts it to an integer. If the text cannot be converted to an integer, an exception is thrown.

number(): Number

Converts an integer to a number, such as 2.num() = 2.0.

num(Text): Number

Parses text and converts it to a number. If the text cannot be converted to a number, an exception is thrown.

text(Integer): Text

Converts an integer to a text, such as 2.text() = "2".

text(Number): Text

Converts a number to a text, such as 2.0.text() = "2.0".

text(Boolean): Text

Converts a Boolean value to a text, such as true.text() = "true".

trunc(Number): Integer

Returns the integer part of a number, such as trunc(5.7)=5 and trunc(-5.2)=-5.

Function may be called directly, such as trim(" Hello") or as method calls, such as " Hello".trim(). It is always the first argument that is the object that the method is called on, for example "abcde".substring(2,4).