Primitive type: character string

Primitive type: character string

A string is just a piece of text.

File syntax

In files, strings are written just as their value:

 string: this is some string

The whitespace at the beginning is removed by the program. Multiline strings are written on a new line, indented by a TAB:

	This is a very long string
	It contains a line break.

Script syntax

In scripts, strings are written between double quotes, "this is a string". The backslash character is used to escape values:

Code Represents
\" A " character
\{ A { character
\n A newline character (line break)
\\ A backslash
\< An escaped < for tagged strings.

Sections between curly braces are interpreted as script code, that is concatentated with the string, for example

 "ab{1 + 1}c" == "ab2c"

This can be nested arbitrarily.

The + operator concatenates strings. Numbers and most other values are automatically converted to strings when needed. This conversion can be forced with the to_string function.

Using the [] or . operator characters in a string can be selected. 0 is the first character:

 "xyz"[0]  ==  "x"
 "xyz".0   ==  "x"  # same thing
 "xyz".1   ==  "y"
 "xyz".2   ==  "z"

It is an error to select characters outside the string

 "xyz".10  # error

See also

tagged string A string containg tags.
to_string Convert any value to a string