<var>

Purpose The <var> clause is used to define a variable within a class. It is not the same as the <var> statement. There is 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 defined in an Object looks like in Run-Time Memory
A variable which is defined in a class will be created in an object when the object is instantiated. Let us assume that the object is called MyStudent and inherits from a class which contains the following variable definition:
<var type="int" name="score">
   100
</var>

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

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 <class name="XStudent" inherit="">
   <construct />
   <scope type="public">
      <var type="int" name="score">
         100
      </var>
   </scope>
</class>

Defines a variable called score with the value of the 100.

Example #2 <class name="XStudent" inherit="">
   <construct />
   <scope type="public">
      <var type="int" name="score">
         100
      </var>
   </scope>
</class>

<node name="MyStudent" class="XStudent" />
<xout>The variable has the value </xout>
<xout>
   <eval object="MyStudent" member="score" />
</xout>

The same variable, score, is defined in the class XStudent and defaulted to the value of 100. The object MyStudent is instantiated and contains the score variable with the initial value. The string The variable has the value 100 is sent to the output stream because 100 is returned as the value of score.

Example #3 <class name="XStudent" inherit="">
   <construct />
   <scope type="public">
      <var type="int" name="score">
         100
      </var>
   </scope>
</class>

<node name="MyStudent" class="XStudent" />
<eval object="score">99</eval>
<xout>The variable has the value </xout>
<xout>
   <eval object="MyStudent" member="score" />
</xout>

The same variable, score, is defined in the class XStudent and defaulted to the value of 100. The object MyStudent is instantiated and contains the score variable with the initial value. The <eval> statement then sets the value of score 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.