All programming languages, including SWiSHscript, make use of a concept called a 'variable'. A variable is analogous to the memory button of a calculator. It can be used to store the result of intermediate calculations and data. Unlike most calculators which only have 1 memory area, SWiSHscript can support multiple variables. The limit is defined by the size and power of your computer system. To allow access to a specific variable, each variable is given a name. The name can include the characters, a...z, A...Z, 0...9, and _ (underscore). The . (dot) and [ ] characters have special meaning, described elsewhere.
Consider the following statement,
x = 3 + 1;
the result of the calculation (3 + 1) is assigned to the variable 'x'.
That variable can be used in subsequent calculations, such as:
y = x * x; // y = 16
x = x + 1; // x = 5, (previous value of x + 1).
Note that // is used to define a comment area. Comments are useful reminders to help you remember exactly what your script does.
Variables can also be used to hold a text message (also called a 'string'), e.g. in this example below. 'message' is a string
message = "Warning do not press that button"