Values
Automate support the following value types:
- Null
- Number
- Text
- Array
- Dictionary
Null
Null is a special keyword denoting a undefined/missing value.
Number
Numbers are stored internally as double-precision 64-bit IEEE 754 floating point values. See Arithmetic operators.
Number literal
Numbers can be represented in expressions with following literals:
- decimal number (base-10) with or without a fractional part and exponent; 123.45
- hexadecimal (base-16) using the 0x prefix; 0xCAFEBABE
- binary number (base-2) : 頭に0bを付ける
Text
Text, or string, is a sequence of characters.
Text literal
テキストはダブルクォーテーションで囲む
"Hello world".
In addition to ordinary characters, you can also include special characters within text literals:
Character |
Description |
{expression} |
String interpolation, see below. |
\b |
Backspace |
\f |
Form feed |
\n |
改行 |
\r |
Carriage return |
\t |
Tab |
\' |
Single quote/Apostrophe |
\" |
Double quote |
\\ |
バックスラッシュ |
\{ |
Avoid interpretation of left curly-bracket as start of a string interpolation |
\uXXXX |
The Unicode character specified by the four hexadecimal digits XXXX. For example, \u00A9 is the Unicode sequence for the copyright symbol. |
String interpolation
String interpolation とは実行中に評価される値を含む文字列を生成する方法。
Each “interpolation” inside a text literal is wrapped in curly brackets;
"1 times 3 is {1*3}".
To format the inserted value add a function name after the expression; "1 times 3 is {1*3;numberFormat}". Any additional arguments are passed to the function as text; "Today is {now;dateFormat;MMM dd}.
Array
An array is a container object that holds a dynamic number of values of any type. Each item in an array is called an element, and are accessed by its numerical integer index. The index is zero-based, first element has index 0, last element has index length - 1. A negative index will access the array from the end (length + index).
To access an array use the subscript operator, length operator and for each block. To modify an array use the array add block, array remove block and array set block.
Array literal
An array literal is a list of zero or more expressions, each of which represents an array element, enclosed in square brackets [ ]:
[ 1, "two", 3.0, null, dict ]
Dictionary
A dictionary is a container composed of エントリ(entry)と呼ばれる"key-value" のペアで構成される。
各キーは高々1回登場する。
- キーはテキストのみ、null を含む文字以外の値は、テキストに変換される。
- 値はどのタイプでも良い
Each entry can also have an associated conversion type, used when communicating with apps supporting other value types.
To access a dictionary use the subscript operator, length operator and for each block. To modify a dictionary use the dictionary put block and dictionary remove block.
Dictionary literal
dictionary literal は、0以上のエントリを持つリストであり、 "{}" で囲まれて表現している。
Dictionary conversion types
Automate では "number", "text", "array", "dictionary" の4つのタイプのみをサポートしている。
Android OS を含む
その他のアプリでは、それ以外の値をサポートしている場合がある。そのため、他のアプリから送られてきたエントリの値は変換される必要がある。
ある値をどんな値に変換するかを特定するために "as" キーワードをキーの後に用いる。
The following conversion types are allowed:
- Boolean
- BooleanArray
- Bundle
- BundleArray
- BundleList
- Byte
- ByteArray
- Char
- CharArray
- CharSequence
- CharSequenceArray
- CharSequenceList
- ComponentName
- ComponentNameArray
- ComponentNameList
- Double
- DoubleArray
- Float
- FloatArray
- Int
- IntArray
- IntList
- Intent
- IntentArray
- IntentList
- Long
- LongArray
- Short
- ShortArray
- String
- StringArray
- StringList
- Uri
- UriArray
- UriList
最終更新:2019年01月13日 17:13