Data Type Specific Members

Navigation:  Widget Designer > Scripting > Object and Member Notation (dot syntax) >

Data Type Specific Members

prev main next

Navigation:  Widget Designer > Scripting > Object and Member Notation (dot syntax) >

Data Type Specific Members

prev main next

Please wait. Due to its content this page might take a while to load...

Each data type in Widget Designer, String, Integer, Double, Boolean, Date, List, Color and JSON, has its own, specific members. Those Members can be used for conversion, editing and information. Those of the members returning a result can even be used with further members.

Please note that these methods only return values, they do not change the object they refer to themselves. One exception here are some members of the color and JSON data types.

The data type of the return value is highlighted in the table below.

Example:

var x = "Hello World!"

var y = x.Contains("llo").ToInteger

DebugMessage(y)

 

The Debug Logger shows "1", as the Boolean value (true) returned by the Contains-member was additionally converted to an integer value (1). The variable "x" keeps its value "Hello World!".

 

Even object properties can be used like this:

"var x = Fader1.Value.Round(2)" assigns the value of Fader1, rounded to two digits, to the local variable "x".

.Contains(search expression)

Returns a Boolean value, indicating if the search expression is included at the object string

Var x = "Hello World"

Label1.Text = x.Contains("ello")

-> Label1 shows "True"

-> Label1 shows "matriarchal"

Member

Description

Example

Data type: String

 

 

.Contains(search expression)

Returns a Boolean value, indicating if the search expression is included at the object string

Var x = "Hello World"

Label1.Text = x.Contains("ello")

-> Label1 shows "True"

.EncodeBytes

Returns a list containing the UTF-8 byte value of each character as integer

Var x = "Hello World"

Var y = x.EncodeBytes

-> y = [72,101,108,108,111,32,87,111,114,108,100]

.EndWith(search expression)

Returns a Boolean value, indicating if the object string ends with the search expression

Var x = "Hello World"

Label1.Text = x.EndWith("orld")

-> Label1 shows "True"

.Format(string representation, ...)

Uses the C# method "String.Format" on the object string and returns the formatted string. For further information on String.Format, please visit https://msdn.microsoft.com/de-de/library/system.string.format(v=vs.110).aspx#Format_Custom or http://timtrott.co.uk/string-formatting-examples/

var x = "I like {0} and {1}."

Label1.Text = x.Format("trains","turtles")

-> Label1 shows "I like trains and turtles."

.IsEmpty

Returns a Boolean value, indicating if the object string contains a value or is empty.

var x = ""

var y = "Hello!"

Label1.Text = x.IsEmpty + " and " + y.IsEmpty

-> Label1 shows "True and False"

.IsMatch(search expression)

Returns a Boolean value, indicating if the search expression is included in the object string. This method is compatible to RegEx (regular expressions). For further information on RegEx, please visit: https://msdn.microsoft.com/en-us/library/az24scfc%28v=vs.110%29.aspx or http://timtrott.co.uk/string-formatting-examples/

Var x = "Hail the Banana King"

Label1.Text = x.IsMatch("(na){2,3}"))

-> searches if x contains the expression "na" two or three times in a row

-> Lable1 shows "True"

.IsNumeric

Returns a Boolean value, indicating if the object string contains a single numeric value. This member is particularly useful for checking a string value before converting it to an integer or double with ".ToInteger" or "ToDouble".

var x = "42"

Label1.Text = x.IsNumeric

-> Lable1 shows "True"

.Left(characters)

Separates the object string at the indicated number of characters (starting at the beginning) and returns all characters of the left split string as a string value

Var x = "mathematical"

Label1.Text = x.Left(6)

-> Label1 shows "mathem"

.Length

Returns an integer with the length of the string object

Var x = "mathematical"

Label1.Text = x.Length

-> Label1 shows "12"

.Locked

Returns a Boolean value, indicating if the object is locked. Only useful for global variables, as they are the only lockable objects. Local variables are always unlocked.

Label1.Text = LocalIP.Locked

-> Label1 shows "True"

.PadLeft(total length, padding character (optional))

Pads the object string with white spaces (or the optional padding character) in front of the expression, until the total length of characters is achieved and returns the respective string

Var x = "BOX"

Label1.Text = x.PadLeft(7,"+")

-> Label1 shows "++++BOX"

.Padright(total length, padding character (optional))

Pads the object string with white spaces (or the optional padding character) behind the expression, until the total length of characters is achieved and returns the respective string

Var x = "BOX"

Label1.Text = x.PadRight(7,"+")

-> Label1 shows "BOX++++"

.Replace(search string, replacement)

Searches the object string for the indicated string and replaces all found strings with the secondly indicated one, the result is also returned as string value

Var x = "mathematical"

Label1.Text = x.Replace("hematic","riarch")

-> Label1 shows "matriarchal"

.Right(characters)

Separates the object string at the indicated number of characters (starting at the end) and returns all characters of the right split string as a string value

Var x = "mathematical"

Label1.Text = x.Right(6)

-> Label1 shows "atical"

.Split(separator)

Splits the object string indicated by the separator and returns a list of all sub strings

var x = "name|date|address"

var y = x.Split("|")

-> y = ["name","date","address"]

.StartsWith(search expression)

Returns a Boolean value, indicating if the object string starts with the search expression

Var x = "Hello World"

Label1.Text = x.EndWith("Hell")

-> Label1 shows "True"

.SubString(start, length)

Returns a sub string of the object string that starts at the indicated index (first character has index 0) and has the indicated length

Var x = "chemically"

Label1.text = x.SubString(3,5)

-> Label1 shows "mical"

.ToCamelCase

Returns the object string formatted to a CamelCase expression

Var x = "WD custom script click"

Label1.Text = x.ToCamelCase

-> Label1 shows "WDCustomScriptClick"

.ToColor

Returns the object string formatted to a color type object, the object string has to be a six-digit hexadecimal value

Var x = "#ABC123"

Label1.text = x.ToColor.G

-> Label1 shows "193" (value of the green component of this color)

.ToDate

Returns the object string formatted to a date type object

Var x = "2016-12-16 15:52:48.593"

Label1.text = x.ToDate.Day

-> Label1 shows "16"

.ToDouble

Returns the value of the object string in double format if the characters form a real number

Var x = "3.14156"

Var y = x.ToDouble

-> y = 3.14156

.ToInteger

Returns the value of the object string in integer format if the characters form a real whole number

Var x = "703"

Var y = x.ToInteger

-> y = 703

.ToJson

Returns the value of the object string in JSON format if the syntax applies to the respective rules for JSON objects

 

.ToLower

Returns the the object string, formatted with only lower case letters.

var x = "WD Custom Script Click"

Label1.Text = x.ToLower

-> Label1 shows "wd custom script click"

.ToSnakeCase

Returns the object string formatted to a Snake Case expression

Var x = "WD Custom Script Click"

Label1.Text = x.ToSnakeCase

-> Label1 shows "wd_custom_script_click"

.ToUpper

Returns the the object string, formatted with only upper case letters.

var x = "WD Custom Script Click"

Label1.Text = x.ToLower

-> Label1 shows "WD CUSTOM SCRIPT CLICK"

.Trim

Returns the object string without any white spaces at the end or the beginning

Var x = "   BOX   "

Label1.text = x.Trim

-> Label1 shows "BOX"

.TrimEnd

Returns the object string without any white spaces at the end

Var x = "   BOX   "

Label1.text = x.TrimEnd

-> Label1 shows "   BOX"

.TrimStart

Returns the object string without any white spaces at the beginning

Var x = "   BOX   "

Label1.text = x.TrimStart

-> Label1 shows "BOX   "

.Type

Returns the type of the respective object as string

Var x = "hypnotized"

Label1.Text = x.Type

-> Label1 shows "String"

.Unescape

 

Returns the object string with the correct formatting concerning "\n" (new line), "\r" (carriage return) and "\t" (tab).

Without unescaping these expressions, they are handled as simple characters.

Var x = "Hello World,\n\r\tHow are you?"

Label1.Text = x.Unescape

-> Label1 shows:

"Hello World,

     How are you?"

Data type: Integer

 

 

.Locked

Returns a Boolean value, indicating if the object is locked. Only useful for global variables, as they are the only lockable objects. Local variables are always unlocked.

Label1.Text = LocalIP.Locked

-> Label1 shows "True"

.ToString

Returns the value of the object integer as a string

Var x = 703

Var y = x.ToString

-> y = "703"

.Type

Returns the type of the respective object as a string

Var x = 703

Label1.Text = x.Type

-> Label1 shows "Integer"

Data type: Double

 

 

.Ceiling

Returns the rounded up value (to a whole number) of the object double as integer value

Var x = 3.14156

Var y = x.Ceiling

-> y = 4

.Floor

Returns the rounded down value (to a whole number) of the object double as integer value

Var x = 3.14156

Var y = x.Floor

-> y = 3

.Locked

Returns a Boolean value, indicating if the object is locked. Only useful for global variables, as they are the only lockable objects. Local variables are always unlocked.

Label1.Text = LocalIP.Locked

-> Label1 shows "True"

.Round(digits)

Returns the value of the double object, rounded to the indicated number of decimals.

Var x = 3.14156

Var y = x.Round(4)

-> y = 3.1416

.ToInteger

Returns the value of the object double as an integer (and rounds the value to a whole number)

Var x = 3.14156

Var y = x.ToInteger

-> y = 3

.ToString

Returns the value of the object double as a string

Var x = 3.14156

Var y = x.ToString

-> y = "3.14156"

.Type

Returns the type of the respective object as a string

Var x = 3.14156

Label1.Text = x.Type

-> Label1 shows "Double"

Data type: Boolean

 

 

.Locked

Returns a Boolean value, indicating if the object is locked. Only useful for global variables, as they are the only lockable objects. Local variables are always unlocked.

Label1.Text = MasterConnectionStatus.Locked

-> Label1 shows "True"

.Not

Returns the negated Boolean value of the object Bool

Var x = True

Var y = x.Not

-> y = False

.ToInteger

Returns an integer for the object value. "False" is converted to "0", "True" to "1"

Var x = True

Var y = x.ToInteger

-> y = 1

.ToString

Returns the value of the object Bool as a string

var x = True

Var y = x.ToString

-> y = "True"

.Type

Returns the type of the respective object as a string

Var x = True

Label1.Text = x.Type

-> Label1 shows "Boolean"

Data type: Date

 

 

.AddDays(days)

Returns the object date plus the indicated amount of days

 

.AddHours(hours)

Returns the object date plus the indicated amount of hours

 

.AddMilliseconds(milliseconds)

Returns the object date plus the indicated amount of milliseconds

 

.AddMinutes(minutes)

Returns the object date plus the indicated amount of minutes

 

.AddMonths(months)

Returns the object date plus the indicated amount of months

 

.AddSeconds(seconds)

Returns the object date plus the indicated amount of seconds

 

.AddYears(years)

Returns the object date plus the indicated amount of years

 

.Day

Returns the object date's days as an integer

 

.DayOfWeek

Returns the weekday of the object's date information as an integer

Var x = Now

Label1.Text = x.DayOfWeek

-> Label1 shows "2" if the script was called on a Tuesday

.DayOfYear

Returns the days of the year of the object's date information as an integer

Var x = Now

Label1.Text = x.DayOfYear

-> Label1 shows "241" if the script was called on August 29th 2017

.DiffDays(date)

Returns the amount of days of difference between the object date and the indicated date as integer

Var x = Now

Var y = x.AddYears(1)

Label1.Text = x.DiffDays(y)

-> Label1 shows "-365"

.DiffHours(date)

Returns the amount of hours of difference between the object date and the indicated date as an integer

Var x = Now

Var y = x.AddDays(5)

Label1.Text = x.DiffHours(y)

-> Label1 shows "-120"

.DiffMilliseconds(date)

Returns the amount of milliseconds of difference between the object date and the indicated date as an integer

Var x = Now

Var y = x.AddSeconds(5)

Label1.Text = x.DiffMilliseconds(y)

-> Label1 shows "-11000"

.DiffMinutes(date)

Returns the amount of minutes of difference between the object date and the indicated date as an integer

Var x = Now

Var y = x.AddDays(5)

Label1.Text = x.DiffMinutes(y)

-> Label1 shows "-7200"

.DiffSeconds(date)

Returns the amount of seconds of difference between the object date and the indicated date as an integer

Var x = Now

Var y = x.AddHours(3)

Label1.Text = x.DiffSeconds(y)

-> Label1 shows "-10800"

.Format(format string)

Uses the C# method "String.Format" on the object date and returns the formatted string. For further information on String.Format, please visit https://msdn.microsoft.com/de-de/library/system.string.format(v=vs.110).aspx#Format_Custom or http://timtrott.co.uk/string-formatting-examples/

Var x = Now (e.g. 12/01/2016 11:45:23)

Label1.Text = x.Format("t")

-> Label1 shows "11:45"

 

.Hour

Returns the object date's hours as an integer

 

.Locked

Returns a Boolean value, indicating if the object is locked. Only useful for global variables, as they are the only lockable objects. Local variables are always unlocked.

Label1.Text = Now.Locked

-> Label1 shows "True"

.Millisecond

Returns the object date's milliseconds as an integer

 

.Minute

Returns the object date's minutes as an integer

 

.Month

Returns the object date's months as an integer

 

.Second

Returns the object date's seconds as an integer

 

.Type

Returns the type of the respective object as a string

Var x = Now

Label1.Text = x.Type

-> Label1 shows "Date"

.Year

Returns the object date's years as an integer

 

Data type: List

 

 

.Avg

Returns the average value of all list items as double.

Var x = [10, 20, 30]

Label1.Text = x.Avg

-> Label1 shows "20"

.Copy

 

 

.Count

Returns an integer with the number of elements of the list object

 

.DecodeBytes

Returns a string decoded from the UTF-8 byte values of each element of the list object. The integers in the list have to range from 0 to 255.

Please also refer to the string member ".EncodeBytes"

Var x = [72,101,108,108,111,32,87,111,114,108,100]

Label1.Text = x.DecodeBytes

-> Label1 shows "Hello World"

.Distinct

Removes duplicate elements from the list and returns the resulting list.

Var x = [10, 20, 30, 10, 10, 20]

Label1.Text = x.Distinct.Join(", ")

-> Label1 shows "10, 20, 30"

.IndexOf(search expression)

Searches for the indicated search expression and returns its index as an integer value. If the expression is contained more than once, the index if the first one is returned, if the expression is not included at all, "-1" is returned

var x = [a, "sdf", 130, 132]

Label1.Text = x.IndexOf(130)

-> Label1 shows "2"

.Join(separator)

Concatenates all items of the list object, separated by the specified separator string, and returns this value as a single string

Var x = [10, 20, 30]

Label1.Text = x.Join("/")

-> Label1 shows "10/20/30"

.Locked

Returns a Boolean value, indicating if the object is locked. Only useful for global variables, as they are the only lockable objects. Local variables are always unlocked.

Label1.Text = LocalIP.Locked

-> Label1 shows "True"

.Max

Searches the list object for the item with the highest value and returns this as an integer value. Only applicable for lists containing solely integer values

Var x = [10, 20, 30]

Label1.Text = x.Max

-> Label1 shows "30"

.Min

Searches the list object for the item with the lowest value and returns this as an integer value. Only applicable for lists containing solely integer values

Var x = [10, 20, 30]

Label1.Text = x.Min

-> Label1 shows "10"

.Remove(index)

Removes the element with the specified index from the original list and returns a Boolean value indicating if the removal was successful.

Var x = [10, 20, 30]

x.Remove(1)

Label1.Text = x.Join("/")

-> Label1 shows "10/30"

.Sort(Boolean expression)

Sorts the list object according to increasing (true) or decreasing (false) values, where the Boolean expression differs between the two methods and returns the sorted list

Var x = [5, 203, 144, 42]

DebugMessage(x.Sort(false))

-> DebugLogger shows "[203,144,42,5]"

.Type

Returns the type of the respective object as a string

Var x = [10, 20, 30]

Label1.Text = x.Type

-> Label1 shows "List"

.WhereRegex(search expression)

Returns a list of all items of the list object where the search expression is included. This method is compatible to RegEx (regular expressions). For further information on RegEx, please visit: https://msdn.microsoft.com/en-us/library/az24scfc%28v=vs.110%29.aspx

Var x = ["banana","handkerchief","Ananas","that's German for 'pineapple'"]

DebugMessage(x.WhereRegEx("(na){2,3}"))

-> searches which elements of x contain the expression "na" two or three times in a row

-> DebugLogger shows "["banana","Ananas"]"

 

Data type: Color

 

 

.A

Returns the alpha value of the object color as an integer (0-255)

Var x = ColorPicker1.SelectedColor

Label1.Text = x.A

-> Label1 shows "255"

.B

Returns the blue value of the object color as an integer (0-255)

Var x = ColorPicker1.SelectedColor

Label1.Text = x.B

-> Label1 shows "255"

.G

Returns the green value of the object color as an integer (0-255)

Var x = ColorPicker1.SelectedColor

Label1.Text = x.G

-> Label1 shows "0"

.Locked

Returns a Boolean value, indicating if the object is locked. Only useful for global variables, as they are the only lockable objects. Local variables are always unlocked.

Label1.Text = LocalIP.Locked

-> Label1 shows "True"

.R

Returns the red value of the object color as an integer (0-255)

Var x = ColorPicker1.SelectedColor

Label1.Text = x.R

-> Label1 shows "128"

.SetRGB(red,green,blue)

Sets the RGB values of the object color

Var x = ColorPicker1.SelectedColor (e.g. R=128 G=0 B=255)

x.SetRGB(100,200,30)

Label1.Text = x.B

-> Label1 shows "30"

.SetRGBA(red,green,blue,alpha)

Sets the RGB values of the object color

Var x = ColorPicker1.SelectedColor (e.g. R=128 G=0 B=255)

x.SetRGB(100,200,30,0)

Label1.Text = x.A

-> Label1 shows "0"

.ToHex

Returns the hexadecimal color value of the object color as a string

Var x = ColorPicker1.SelectedColor (e.g. R=128 G=0 B=255)

Label1.Text = x.ToHex

-> Label1 shows "#8000FF"

.Type

Returns the type of the respective object as a string

Var x = ColorPicker1.SelectedColor

Label1.Text = x.Type

-> Label1 shows "Color"

 

One special data type is JSON, it enables you to store large sets of data and edit and retrieve this information for other purposes. The "location" of a JSON element is the key (e.g. "arr"), or in case of nested maps the path expressed with a dot syntax (e.g."map.b"). If you are interested in the use of JSON objects, please refer to the chapter Using JSON.

Data type: JSON

 

 

.Add(array location,value)

Adds a new item to an array at the specified location and returns the changed JSON array (optional)

var x = '{"arr":[12,34,56], "map":{"a":1.2, "b":2.3, "c":3.4}}'.ToJson

Label1.text = x.Add("arr", 78).ToInteger

-> Label1 shows "[12,34,56,78]"

.Clear(map location)

Removes all child items at the specified location and returns the JSON element containing the changed item (optional)

var x = '{"arr":[12,34,56], "map":{"a":1.2, "b":2.3, "c":3.4}}'.ToJson

Label1.text = x.Clear("map")

-> Label1 shows "{"arr":[12,34,56],"map":{}}"

.Count(array or map location)

Returns the number of child items at the specified location as an integer value. If the location is not a map or an array, an exception is thrown

var x = '{"arr":[12,34,56], "map":{"a":1.2, "b":2.3, "c":3.4}}'.ToJson

Label1.text = x.Count("map")

-> Label1 shows "3"

.Get(location)

Returns the value at specified location as a JSON expression

var x = '{"arr":[12,34,56], "map":{"a":1.2, "b":2.3, "c":3.4}}'.ToJson

Label1.text = x.Get("map.b").ToString

-> Label1 shows "2.3"

.GetDate(location)

Returns the value at the specified location as a date value. If the value cannot be converted, a default value is returned

var x = '{"start":"2016-02-03"}'.ToJson

Label1.text = x.GetDate("start").Month

-> Label1 shows "2"

.GetDouble(location)

Returns the value at the specified location as a double value. If the value cannot be converted, a default value is returned

var x = '{"arr":[12,34,56], "map":{"a":1.2, "b":2.3, "c":3.4}}'.ToJson

Label1.text = x.GetDouble("map.a")

-> Label1 shows "1.2"

.GetInteger(location)

Returns the value at the specified location as an integer value. If the value cannot be converted, a default value is returned

var x = '{"arr":[12,34,56], "map":{"a":1.2, "b":2.3, "c":3.4}}'.ToJson

Label1.text = x.GetInteger("map.c")

-> Label1 shows "3"

.GetString(location)

Returns the value at the specified location as a string value.

var x = '{"arr":[12,34,56], "map":{"a":1.2, "b":2.3, "c":3.4}}'.ToJson

Label1.text = x.GetString("arr")

-> Label1 shows "[12,34,56]"

.Keys(optional array or map location)

Returns a list of all keys/indices at the specified location

var x = '{"arr":[12,34,56], "map":{"a":1.2, "b":2.3, "c":3.4}}'.ToJson

Label1.text = x.Keys("map")

-> Label1 shows "["a", "b", "c"]"

.Locked

Returns a Boolean value, indicating if the object is locked. Only useful for global variables, as they are the only lockable objects. Local variables are always unlocked.

Label1.Text = LocalIP.Locked

-> Label1 shows "True"

.Set(location, value)

Changes the value or defines a new one at the specified location and returns the JSON element containing the changed item (optional)

var x = '{"arr":[12,34,56], "map":{"a":1.2, "b":2.3, "c":3.4}}'.ToJson

Label1.text = x.Set("map.a",123).ToString

-> Label1 shows "{"a":123,"b":2.3,"c":3.4}"

.ToString(location)

Returns the JSON object as a string

var x = '{"start":"2016-02-03"}'.ToJson

Label1.text = x.GetDate("start").Month

-> Label1 shows "{"start":"2016-02-03"}"

.Type

Returns the type of the respective object as a string

var x = '{"start":"2016-02-03"}'.ToJson

Label1.Text = x.Type

-> Label1 shows "Json"

.Values(array or map location)

Returns a list of all values at the specified location

var x = '{"arr":[12,34,56], "map":{"a":1.2, "b":2.3, "c":3.4}}'.ToJson

Label1.text = x.Values("map").Join(", ")

-> Label1 shows "1.2, 2.3, 3.4"

 

The object data type is always applied when it is not possible to determine the specific type of an object beforehand, e.g. for list elements, local variables without a value assigned or for the return value of a function.

Data type: Object

 

 

.ToDate

Returns the object content formatted to a date type object

Var x = ["a","2017-03-17",123.456,true,[3,6,9]]

Label1.Text = x[2].ToDate.Year

-> Label1 shows "2017"

.ToDouble

Returns the value of the object content in double format if the characters form a real number

Var x = ["a",b,123.456,true,[3,6,9]]

Fader1.Value = x[2].ToDouble

-> Fader1 will take the value 123.456

.ToInteger

Returns the value of the object content in integer format if the characters form a real whole number

Var x = ["a",b,123,true,[3,6,9]]

Fader1.Value = x[2].ToInteger

-> Fader1 will take the value 123

.ToJson

Returns the value of the object content in JSON format if the syntax applies to the respective rules for JSON objects

 

.ToList

Returns the object content formatted to a list type object

Var x = ["a",b,123,true,[3,6,9]]

Label1.Text = x[4].ToList.Avg

-> Label1 shows "6"

.ToString

Returns the object content formatted to a string type object

Var x = ColorPicker1.SelectedColor (e.g. R=128 G=0 B=255)

Label1.Text = x[0].ToString

-> Label1 shows "a"

.Type

Returns the type of the respective object as a string

Var x

Label1.Text = x.Type

-> Label 1 shows "Object"