WML - Variables

Advertisements


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:

AttributeValueDescription
namestringSets the name of the variable
valuestringSets the value of the variable
classclass dataSets a class name for the element.
idelement IDA 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>

Using Variables:

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 option value is $(b) </p>


Advertisements
Advertisements