Generally speaking, a variable is a fundamental programming concept. It is a stand-in for data in a program that can be changed, added to, or removed, not unlike how 'x' is used in algebra. In CAOS, there are script- and agent-specific (VAxx, OVxx) variables, as well as game- and world-specific ones (GAME. EAME). Unlike most other scripting languages, script- and agent-specific variables in CAOS don't inherently have names, only ID numbers-- see NAME, however. A common CAOS error is "Incompatible type agent or decimal or string expected", caused by using the wrong kinds of procedures on a variable type.
CAOS variables can store numbers, floats (numbers with a decimal point), strings (groups of 1 or more letters), and references to specific agents. Variables can generally be substituted where you might use a static (unchanging) number or string, but unlike that information, they can be changed during their lifetime. For example, these two scripts are equivalent:
sets va00 "cat" sets va01 "dog" adds va00 va01 outs va00
Strings that include numbers are a fraught case; CAOS programmers should take care not to confuse e.g. the string "9" with the number 9, and vice versa. See TYPE.
Many CAOS commands use or act on variables. The following are particularly relevant:
- VAxx, OVxx and MVxx, the numbered variables
- NAME, MAME and GAME, named variables
- SETV and SETS, for input
- OUTV and OUTS, for output
|This stub could use .|