You can declare variables using the <var> element or the name attribute of various form items. Table 1 lists the possible variable scopes:
| Scope | Description | Implementation details |
|---|---|---|
| anonymous | Used by the <block>, <filled>, and <catch> elements for variables declared in those elements. | Supported as documented in VoiceXML 2.1. |
| application | Variables are visible to the application root document and any other loaded application documents that use that root document. | Supported as documented in VoiceXML 2.1. The following application variables
have been added to hold the audio recorded during speech recognition:
|
| dialog | Variables are visible only within the current <form> or <menu> element. | Supported as documented in VoiceXML 2.1. |
| document | Variables are visible from any dialog within the current document. | Supported as documented in VoiceXML 2.1. |
| session | Variables that are declared and set by the interpreter context. | The following session variables are fully supported:
II Digit (Information Indicator Digit) and User to User Information functionality are not available. |
To ensure that your application is portable, you should check if session variables are defined before attempting to use them:
<if cond="session.x==undefined">
<exit>
<else>
ok to access the session variable
<endif>
To see how to encrypt the memory used for variables in VoiceXML, see VoiceXML internal variable encryption