String Elements

A string is a sequence of text characters that is frequently used to get information from a user and to show text on a screen. ViviFire code can contain string literals, string constants, and string variables.

String literals

A string literal is a indication of a string value written in code. ViviFire's string literals can show most characters.

A basic string literal contains printable characters between a pair of double-quotation symbols (" "). Here is an example:

PrintLine "This is a basic string literal."
Output:
This is a basic string literal.

Multi-line strings

A string literal can become long. It can become too long to read easily if you must scroll horizontally. One solution is to divide the string into many smaller strings and concatenate them at runtime. If this code runs a small number of times, this could be a good solution. But, if this code must run frequently, it can make your program slower.

ViviFire lets you write one string literal on many lines. You write an underscore symbol (_) after the first line. All lines between the first and last have one underscore before and one underscore after. Then the last line starts with an underscore. An example follows.

Const quote =
    "The following two statements are usually both true: "_
    _"There's not enough documentation. "_
    _"There's too much documentation. "_
    _"-- Larry Wall"

Interpolated strings

An interpolated string literal concatenates embedded expressions into one string value. Such literals can be much easier for you to read. The example that follows makes a string without interpolation.

Const a = 5
Const b = 10
PrintLine "The sum of " & a & " and " & " is " & (a + b) & "."
Output:
The sum of 5 and 10 is 15.

This is not easy to read, and becomes worse with more expressions.

An interpolated string starts with the dollar and quotation symbols ($"). You write an embedded expression between a pair of braces ({ }).

The equivalent code with interpolation:

Const a = 5
Const b = 10
PrintLine $"The sum of {a} and {b} is {a + b}."

String constants

A string constant is an indication of a short string value in code. A constant has a length a minimum of one character. And only a small number of constants are longer than this.

A string constant starts with a dollar symbol ($). After that, you can write a number or a name. The syntax follows:

One of these
$ decimal
$B binary
$O octal
$U hexadecimal
$X hexadecimal
$ name
decimal
A decimal (base-10) integer.
binary
A binary (base-2) integer.
octal
An octal (base-8) integer.
hexadecimal
A hexadecimal (base-16) integer.
name
An abbreviation for a frequently used string.

For a list, see Pre-Calculated Constants.

Mixtures of string constants and string literals

TODO

String variables

TODO