Strings
Strings are a plain sequence of alphanumerical characters -
letters, numbers or symbols - which are mostly used for messages, or for identifiers of objects such as projects (documents), actions, buffers, programmers (end devices), etc.
They are defined this way:
string name = "characters";
Defines a
string with the given name and initializes it to the content characters between
double quotation marks.
Remarks:
- Special characters in the string can be given with a backslash: \n = Line feed, \" = double quote, \\ = back slash.
- Strings can be compared with the == operator, f.i. if (sDocument == "document0") ...
- Strings can be concatenated with the +, += operators, f.i. string s = "Hello " + "World";
- Strings can be repeated with the *, *= operators, f.i. string s = "Hello " * 2;
- Arrays of strings can be defined just as arrays of variables.
Example:
string device_name = "device";
string empty_str = "";
string[] MyStringArray;
The string class has the following functions:
string.length(): int
returns the number of characters in the string.
string.toInt(): int
returns the integer number represented by the string.
string.toDouble(): double
returns the double floating point number represented by the string.
Strings can be formatted with the message function and the << pipe operator. The content between %..% is replaced by the pipe in order of appearance, e.g:
message("Variable %p1% has the content %p2%") << "Test" << 12;
// results in the string "Variable Test has the content 12"
See also:
Variables, structs, functions, print, message
► latest
version online