<var>
Declares a variable.
Syntax
<var
name="string"
expr="js_expression"
/>
Description
Declaration of a variable in the scope of the enclosing element.
| Attribute |
Description |
name
|
Variable name, which must be a valid JavaScript identifier that does not begin with the underscore character (_) or end with the dollar-sign character ($); it may not be a reserved keyword in either JavaScript or Java.
|
expr
|
JavaScript expression that assigns the initial value of the variable. Optional (default is either undefined or the current value of the variable, if already declared in this scope).
|
If a <var> element names a variable that is already in scope, it declares a new variable with the same name. If the <var> element has an expr attribute, the variable is assigned the specified value; otherwise, the variable is assigned the value undefined.
|
|
Tip:
|
| | If a JavaScript expression contains any of the characters "<", ">", or "&", that character must be replaced with the corresponding escape sequence "<", ">", or "&". For more information, see JavaScript Quick Reference. |
|
Usage
See Also
Examples
<?xml version="1.0" ?>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
"http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<form id="foo">
<var name="a"/>
<var name="b"/>
<var name="result"/>
<block>
<assign name="a" expr="10"/>
<assign name="b" expr="35"/>
<assign name="result" expr="a * b"/>
</block>
<block>
<prompt>
<value expr="a"/> multiplied by <value expr="b"/> equals
<value expr="result"/>
</prompt>
</block>
</form>
</vxml>
[Show Frames] [FIRST] [PREVIOUS] [NEXT]