Literals
| Form | Type | Examples | Notes |
|---|---|---|---|
| Decimal integer | Integer | 0 42 1000000 | 64-bit signed. No digit separators, no suffixes. A leading - is the unary minus operator, not part of the literal. |
| Hex integer | Integer | 0x7B 0XFF 0x8000 | 0x or 0X, then hex digits in either case. Gives exactly the same value as the decimal form: 0x7B == 123. |
| Real | Real | 0.5 3.14159 100.0 | Needs digits on both sides of the dot. .5, 5. and exponents like 1e3 aren't valid. |
| Text | Text | "hello" "" "Ünïcødé ✓" | Double quotes only. 'a' is an error. Any Unicode text is allowed. See the escapes below. |
| Boolean | Bool | true false | Lowercase only. |
| Named constant | Integer | VirtualKey.F5 MouseButton.Right | Replaced by its number when the script compiles. See Named constants. |
Integer literals are read through a 64-bit float, so anything above 2⁵³ (9,007,199,254,740,992) loses precision. Values beyond the signed 64-bit range aren't supported.
String escapes
| Write | Get |
|---|---|
\n | a line feed (U+000A) |
\r | a carriage return (U+000D) |
\t | a tab |
\" | a double quote |
\\ | a single backslash |
\ at the end of a line | nothing: a line continuation. The backslash and the line break are both dropped. |
\ followed by any other character | that character, without the backslash. "\q" is "q". |
warning
Windows paths: "C:\temp\new" is not a path. \t becomes a tab and \n a line break.
Double every backslash ("C:\\temp\\new"), or build the path with
ShellExpandEnvironmentVariables("%TEMP%\\new").
There's no \x.. or \u.... escape. Write a Windows line ending as \r\n. A string literal can also contain a
real line break. The compiler accepts it, but the editor colors the rest of the line as an
unterminated string, so the \ continuation or \n is the tidier way to write a multi-line
string.
path = "C:\\Users\\Public\\notes.txt"; // C:\Users\Public\notes.txt
quoted = "She said \"hi\""; // She said "hi"
twoLns = "first\nsecond"; // two lines
long = "This is all one line of text, \
split in the source for readability."; // no line break in the value