ColdC provides two kinds of variables, local variables and object variables. Local variables are used within methods to temporarily store data. In order for a local variable to be used it must first be declared at the top of the method in a var declaration (see section Defining Methods). Object variables are defined on an object, and can be used to store data for an indefinite period of time (at least until the object is destroyed). More information on Variables can be found in the section Objects and Variables.
When a variable is evaluated as an expression, its value is that of its contents (the data stored in the variable name). Initially variables will contain the integer data value of zero (0). To set the contents of a variable, use the assignment expression.
The value of a local variable is specific to the currently executing method frame. When the method is invoked at another time all of the local variables begin again with the value of zero (0).
If the variable is a local variable, it must be declared as a local variable at the top of the method (see Defining Methods). If it is not declared at the top of the method, the interpreter will assume it is an object variable. In the case that both a local variable and an object variable have the same name, the local variable will take precedence.
It is possible to indirectly access and set data on an object variable using the functions get_var() and set_var(). Normally, an object variable is accessed and set just as if it were a local variable. These functions are useful for indirectly setting or accessing the variable, or for when there is a possible conflict with a local variable. If the variable is not declared in the method, the interpreter will always assume it is an object variable.
Data | Operators | Variable Expression | Function Call Expression | Method Call Expression | Error Handling Expression | Looping Expressions