String
The term "string" in MegaZeux is now most commonly used to refer to string variables, introduced in a limited capacity in version 2.62. MZX also refers to any value enclosed in quotes (") in Robotic code as a string, with interpretation dependent on context. However, this meaning is so trivial and general that it would be more productively explored in specific articles on Robotic functionality.
Basic String Syntax
String variables (henceforth referred to as "strings" for brevity) work in much the same way as counters, in terms of where and how they can be used in Robotic. Any counter name prefixed with a dollar sign ($) is interpreted as a string. Like counters, strings can be assigned to with set, interpolated with ampersands (&), compared with an if branch (limited to equality and inequality), and read and written to and from files. Strings can also be concatenated using the inc command. The value assigned to a string depends on context:
set "$string" to 42 sets a string to the text "42", from a literal value set "$string" to "42" sets a string to the text "42", from a literal string value set "$string" to "counter" sets a string to the text "counter", a literal string value set "$string" to "&counter&" sets a string to the value of the counter "counter", via interpolation set "$string" to "$string2" sets a string to the value of another string, "$string2". set "$string" to "fread" sets a string to a value read from a file, terminated by an asterisk (*) set "$string" to "fwrite" does NOT set, but WRITES a string to a file, terminating it with an asterisk (*) set "$string" to "board_name" sets a string to the name of the current board
As you can see, there are three basic cases and some special considerations. First, a string set to a numeric literal becomes a string representation of that number. Second, a string set to a STRING literal becomes (in most cases), that literal, NOT a counter named by that literal. In order to set a string to the value of a numeric counter, that counter must be interpolated into the string literal. Finally, a string can be set to another string (i.e. when the second value also begins with $). However, in addition to these general cases, there are also some special keywords interpreted as built-in string values instead of literals. Currently, these include "fread" and "fwrite", and both of these followed by a number value, for file access; "robot_name", "board_name", and "mod_name", which return the name of the currently executing robot, the current board, and the currently playing module music file; and "INPUT", which is itself interpreted as a string, and is the value returned from an "input string "Prompt"" command. In order to actually set a string to these literal values (or a literal string beginning with $ for that matter), it must be specially constructed using other commands.