<var>

Purpose The <var> statement is used to define a variable within the main part of a Superx++ program or within a method. It is not the same as the <var> clause. There is however no syntactical difference in their formats.
Format <var type="{datatype}" name="{name}">
   {value}
<var>

{datatype} the datatype of the variable
{name} the name of the variable
{value} (optional) the initial value of the variable

What a variable looks like in Run-Time Memory
A variable which is defined with the following statement:
<var type="int" name="score">
   100
</var>

will look like this in run-time memory (assuming run-time memory was empty beforehand):
<xppRAM var_int_score="100" />

where xppRAM is the memory object.


Renderings of a variable with Various Datatypes in Run-Time Memory
Datatype Rendering in Run-Time Memory
bool var_bool_{variable name}="{value}" />
date var_date_{variable name}="{value}" />
double var_double_{variable name}="{value}" />
float var_float_{variable name}="{value}" />
int var_int_{variable name}="{value}" />
long var_long_{variable name}="{value}" />
short var_short_{variable name}="{value}" />
string var_string_{variable name}="{value}" />
{variable name} name of the variable
{value} value of the variable

Example #1 <var type="int" name="score">
   100
</var>

Defines a variable called score which has the value of 100.

Example #2 <var type="int" name="score" />
<eval object="score">99</eval>
<xout>The variable has the value </xout>
<xout>
   <eval object="score" />
</xout>

The same variable, score, is defined and set to 99. The string The variable has the value 99 is sent to the output stream because 99 is returned as the value of score.