Default Data Types

Text

A text variable, can be set when using the set assignment statemet followed by a string. A text variable value should be always in quotes.

Setting a string- text value

set textvar to 'Hello World'
textvar is a text variable.

Using three quotes in a text variable can be used to declare a multiple line text variable.

set textvar to '''This can be used 
to set a 
multiline text.'''

Text data type properties

Name Type Description
Length Numeric The length (in characters) of the text stored into the variable.

Numeric

Numeric variable values can be set using a number in the command.

set num to 6

Setting a decimal numeric value should always have a dot as the decimal point.

set num to 6.3
Setting a hexadecimal value
set hexnum to 0x0000
Setting a octadecimal value
set octnum to 0o0000

Boolean

A Boolean variable can be set using the comparison operators

set boolvar to 3!=3
Another way to set a boolean variable is using the logical operators.
set boolvar to 3=4 or 10>1

In this case despite 3 is not equal to 4, the boolvar variable would be true as the second condition is valid.

Alternatively, a boolean variable can be set using the words true or yes and false or no.
set boolvar to True
set boolvar to no
A boolean variable can only have a True or False value.

Examples

set boolvar1 to True
set boolvar2 to no
set boolvar3 to 'a' not in 'abcd'
In the above examples, boolvar1 is true, while boolvar2 and boolvar3 are false.

Boolean through workstation conditions

Any action which provides a boolean variable result, can be used as a variable value using parenthesis (). In the example below, the file exists action is used.

set boolvar to (File.Exists File: "C:\file.txt")

In this example, the value of boolvar if such file exists will be true.

The list below includes the actions that may be used this way.

  • Services.Installed
  • Services.Paused
  • Services.Running
  • Services.Stopped
  • File.Exists
  • Folder.Exists
  • Folder.Empty

DateTime

A DateTime variable can be set by a date-time related action such as the “DateTime.Current” which retrieves the current date and time.

Alternatively, a datetime variable can be set by using the following format: d”yyyy-MM-dd HH:mm:ss.fff+zz” where y is the year, M is the month, d the day, H the hours, m the minutes, s the seconds, f the miliseconds and zzz the offset from UTC.

All date fields of a datetime variable are mandatory. The time fields are optional. If a time field is populated, the higher fields are required as well.

set dtvar to d"2019-07-16 14:30:00.000+00"

The value of the dtvar corresponds to the 14.30 UTC on the 15th of July 2019.

The accepted notations appear in the table below:

DateTime Field Notation Digits Mandatory
Year yyyy 4 Yes
Month MM 1-2 Yes
Day dd 1-2 Yes
Hour HH 1-2 No
Minutes mm 1-2 No
Seconds ss 1-2 No
Miliseconds fff 1-3 No
UTC Offset zzz 1-3 No

In regard to the separators, date can be separated using a slash, a dash or a dot (/, -, .) while the time can be separated using a colon (:).

A DateTime variable can also be set by a date-time related action such as the “DateTime.Current” which retrieves the current date and time.

DateTime.Current DateTimeFormat:DateTimeFormat.DateAndTime Offset:'0' CurrentDateTime=> CurrentDateTime

DateTime data type properties

Name Type Description
Year Numeric The year part of the DateTime value.
Month Numeric The month part of the DateTime value.
Day Numeric The day part of the DateTime value.
DayOfWeek Text The name of the day (e.g. Sunday, Monday etc)
DayOfYear Numeric The day of the year part of the DateTime value (1-365 or 366 for leap years)
Hour Numeric The hour part of the DateTime value.
Minute Numeric The minute part of the DateTime value.
Second Numeric The seconds part of the DateTime value.

List

A list of values is considered as a list data type. If the list consists of the same type items, then the list is considered as of that type. (i.e. List of text values) If the list consists of more than one items, then it’s a list of general values.

To form a list, use square brackets. This is a list of numeric values.

set numericlist to [1,2,3,4]
Similarly, this is a list of text values

set textlist to ["Hello","World","This","is","a","list"]

Below, the two lists are combined forming a list of general values.

set GeneralList to ["Hello","World","This","is","a","list",1,2,3,4]
Note, that nested lists can be formed using curly brackets which have each row enclosed. For example the below list displays
set nestlist to [["London","New York","Tokyo"],[1,2,3]]

List data type properties

Name Type Description
Count Numeric The number of items within the list.

Data Table

A data-table can be formed using curly brackets which have each row enclosed. For example the below data table displays users names and their age.

set dtvar to {['John', 24], ['Catherine', 27], ['Mary', 35] }
This will result to the below.

John 24
Catherine 27
Mary 35

Using a caret, the headers of the data table can be included as well. The header values need to be set in the first row.

set dtvar to {^['Name','Age'],['John', 24], ['Catherine', 27], ['Mary', 35] }

Now the data table looks like this.

Name Age
John 24
Catherine 27
Mary 35

Note that the below syntax can be used to form an empty data table.

set x to {}

Despite the fact that the Data Table type does not have an actual property to extract, note that the number of rows and columns can be extracted using the .rows.count and .columns.count respectively.

Data Row

One of the default data types is the data table row. To assign a value to a data row variable, a data table is required. Using the above example, the first row will be set as the value of a data row.

set drvar to dtvar[0]

Robin is zero based and the order of data rows always starts from 0.

Custom Object

A custom object is a data type that can be used in order to include custom properties for values.

In this example a custom object is used for a country. The attributes used are the name, capital, population and the country code.

set CustObjectVar to { 'Country': 'France', 'Capital': 'Paris', 'Population': 66998000,'ISO 3166 code': 'FR' }

Note, that the below syntax can be used to form an empty custom object.

set x to {{}}

General Value

A variable having multiple value types will be considered as a general value.

In the example below the variable “genvar” is a general value as it’s used in two different methods through the automation.

During the execution of the first command, genvar will be a number. After the execution of the second command, it will be considered as a text variable.

set genvar to 10
set genvar to 'robin'