<var>
Declares a variable.
Note: All variables (even those used in scripts) must be declared.
Attributes
This section describes the attributes you can set for this element.
|
Name |
Data type |
Default |
|---|---|---|
|
CDATA |
optional |
|
|
NMTOKEN |
required |
expr
The expr attribute is included in a declaration to assign an initial value, for example:
<var name="count" expr="0" />
Note: If the expr attribute is not specified when a variable is declared, the variable is set to undefined upon initialization.
name
The name attribute specifies the name of a variable, for example:
<var name="sizes" />
Note: In VoiceXML, certain key words are reserved for use by the interpreter. As a result, you cannot use the following key words for variable names: anonymous, application, dialog, document and session.
Children
None.
Parents
Sample code
<form>
<var name="mydur" expr="0"/>
<transfer name="mycall" dest="phone://18005551234"
connecttimeout="30s" bridge="true">
<filled>
<assign name="mydur" expr="mycall$.duration"/>
<if cond="mycall == 'busy'">
<prompt> Sorry, our lines are busy. Please try
again later.</prompt>
<elseif cond="mycall == 'noanswer'"/>
<prompt> Sorry, our business hours are 9 am to 7 pm,
monday through friday</prompt>
</if>
</filled>
</transfer>
</form>
For a VoiceXML sample demonstrating the use of the <var> element, see Blackjack.vxml located in $NVP_HOME/appservice/applications/webapps/BlackJack .