Type: String

From Waltz
Jump to navigation Jump to search

This documentation is partially reproduced from the excellent Mozilla Developer Network Reference for JavaScript.

The String type represents words and other characters strung together into a single String. Strings are how Waltz represents text. A String can contain any character (although some characters may accidentally end the declaration of a String early without being properly escaped.)

Constructing

There is no need to explicitly construct a String, nor is there an explicit constructor. Assigning a literal string value is enough to create a String. A string literal is zero or more characters enclosed in double (") or single (') quotation marks. A string must be delimited by quotation marks of the same type; that is, either both single quotation marks or both double quotation marks. The following are all examples of Strings:

'foo'

"bar"

'1234'

"Man's best friend!"

In addition to ordinary characters, you can also include special characters in Strings, as shown in the following example:

'one line \n another line'

The following table lists the special characters that you can use in Strings.

Character Meaning
\0 Null Byte
\b Backspace
\f Form Feed
\n New Line
\r Carriage Return
\t Tab
\v Vertical Tab
\' Apostrophe or single quote
\" Double quote
\\ Backslash character
\XXX The character with the Latin-1 encoding specified by up to three octal digits XXX between 0 and 377. For example, \251 is the octal sequence for the copyright symbol.
\xXX The character with the Latin-1 encoding specified by the two hexadecimal digits XX between 00 and FF. For example, \xA9 is the hexadecimal sequence for the copyright symbol.
\uXXXX The Unicode character specified by the four hexadecimal digits XXXX. For example, \u00A9 is the Unicode sequence for the copyright symbol.
\u{XXXXX} Unicode code point escapes. For example \u{2F804} is the same as the simple Unicode escapes \uD87E\uDC04.

Permitted Values

Any sequence of characters is permitted in a String, although, as mentioned in Constructing, some characters requires special escape characters.

Primitive Bridging

The String type exists in both Waltz's native context as well as in its Script Expressions. Strings are freely converted with no change in content except to properly escape a double quote mark used instead a string declared with single quote marks. This process is transparent and requires no special handling.

Types
Primitives Boolean · Number · String
Objects Color · Dimension · DmxMultiverse · DmxUniverse · LocalInterface · Material · Point · RemoteAddress/IP · Scene · Time · Touch
Node Specific NdiSource · WoControlCue · WoHitTestResult · WoTimeline
Collections List · List of Lists · Map · Varargs
Special Any · Consumer · Expression · Null · Void