WML - Variables
Because multiple cards can be contained within one deck, some mechanism needs to be in place to hold data as the user traverses from card to card. This mechanism is provided via WML variables.
WML is case sensitive. No case folding is performed when parsing a WML deck. All enumerated attribute values are case sensitive. For example, the following attribute values are all different: id="Card1", id="card1", and id="CARD1".
Variables can be created and set using several different methods. Following are two examples:
The <setvar> element:
The <setvar> element is used as a result of the user executing some task. The >setvar> element can be used to set a variable's state within the following elements: <go>, <prev>, and <refresh>.
This element supports the following attributes:
|name||string||Sets the name of the variable|
|value||string||Sets the value of the variable|
|class||class data||Sets a class name for the element.|
|id||element ID||A unique ID for the element.|
The following element would create a variable named a with a value of 1000:
<setvar name="a" value="1000"/>
The input elements:
Variables are also set through any input element like input,select, option, etc. A variable is automatically created that corresponds with the named attribute of an input element.
For example, the following element would create a variable named b:
<select name="b"> <option value="value1">Option 1</option> <option value="value2">Option 2</option> </select>
Variable expansion occurs at runtime, in the microbrowser or emulator. This means it can be concatenated with or embedded in other text.
Variables are referenced with a preceding dollar sign, and any single dollar sign in your WML deck is interpreted as a variable reference.
<p> Selected o