US: 800.995.PLUM UK: 0845.355.3330
US: 800.995.PLUM UK: 0845.355.3330
A variable is a facility for storing a piece of data in memory while associating it with a memorable name. Variables are widely used in computer programming as they allow programmers to create more readable code. Variables usually store one type of value at a time, although some languages allow them to hold more complicated structured data. The most commonly encountered types of variables are integers, floating point numbers, strings, booleans, arrays or lists, and key-value maps.
Access to a variable is controlled by the scope of the variable. Variables within a VoiceXML application fall within different scopes depending on where the variables are declared. There are five scopes within VoiceXML. These are: session, application, document, dialog, and anonymous.
session-scoped variables are created by the platform and are read-only. These variables contain information related to the specific session that is occurring at that time. Plum uses three different session variables: session.telephone.ani, session.telephone.dnis, and session.id.application-scoped variables are global variables that were declared within the root document. These variables can be reached from any page of an IVR application as long as the page references the root document in the application attribute of the <vxml/> element.document-scoped variables are variables related to one page of an IVR application. These variables must be declared as a direct child element of the <vxml/> element. Declaring them within a different element such as <form/> or <field/> will cause the variable to be in a lesser scope.dialog-scoped variables are variables declared within a <form/> or <menu/> element. If the application were to leave the designated <form/> or <menu/>, those variables would go out of scope and would no longer be accessible. anonymous-scoped variables are declared within a <block/>, <filled/>, or <catch/> element. When the application leaves the element the variables within the element go out of scope and are no longer accessible.Variables in VoiceXML also have specific rules on naming. All variable names must conform to the ECMAScript specification: they may consist only of letters, numbers, or the underscore character, and must begin with a letter. Variables that begin with an underscore or end with a dollar sign are reserved for the VoiceXML interpreter and cannot be used.
| © 2013 The Plum Group, Inc. |