Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

clear

Resets the specified form items.

<clear 
namelist = "form_item1 form_item2 ..."
/>

namelist

The name of the form item(s) to clear.

The clear element resets the variable, prompt counters, and event counters of the specified form item(s).

If the namelist attribute is not specified, all form items are reset. If any form items specified by the namelist do not exist, then prior to Revision 3, the interpreter ignores them. In Revision 3 and later, the interpreter throws error.semantic in that situation.

You can also use clear to clear a variable declared using the var element.

The following example asks the user to say the name of a fruit. If the user says "repeat", the form item variable is cleared, and the prompt is replayed. Note that when the user says help, the form item variable need not be cleared. When the Platform detects that the user has uttered help, it fires the help event handler but does not fill the form item variable.

<?xml version="1.0"?>
<vxml version="2.1"
 xmlns="http://www.w3.org/2001/vxml">
   <link event="help">
      
      <grammar mode="voice"
         root="root_rule"
         tag-format="semantics/1.0"
         type="application/srgs+xml"
         version="1.0"
         xml:lang="en-US">
            <rule id="root_rule" scope="public">
                  <one-of>
                        <item weight="1.0">
                              help
                        </item>
                  </one-of>
            </rule>

      </grammar>

      
      <grammar mode="dtmf"
         root="root_rule"
         tag-format="semantics/1.0"
         type="application/srgs+xml"
         version="1.0">
            <rule id="root_rule" scope="public">
                  <one-of>
                        <item>
                              0
                        </item>
                  </one-of>
            </rule>

      </grammar>

   </link>

   <form id="pick_fruit">   

   <field name="fruit">
      <prompt>
      Pick a fruit
      </prompt>

      
      <grammar mode="voice"
         root="root_rule"
         tag-format="semantics/1.0"
         type="application/srgs+xml"
         version="1.0"
         xml:lang="en-US">
            <rule id="root_rule" scope="public">
                  <one-of>
                        <item>
                              <one-of>
                                    <item>
                                          apple
                                    </item>
                              </one-of>
                              <tag>out.fruit = "apple";</tag>
                        </item>
                        <item>
                              <one-of>
                                    <item>
                                          orange
                                    </item>
                              </one-of>
                              <tag>out.fruit = "orange";</tag>
                        </item>
                        <item>
                              <one-of>
                                    <item>
                                          pear
                                    </item>
                              </one-of>
                              <tag>out.fruit = "pear";</tag>
                        </item>
                        <item>
                              <one-of>
                                    <item>
                                          repeat
                                    </item>
                              </one-of>
                              <tag>out.fruit = "repeat";</tag>
                        </item>
                  </one-of>
            </rule>

      </grammar>


      <noinput>
         I'm sorry. I didn't hear you.
         <reprompt/>
      </noinput>

      <help>
         Say apple, orange, or pear.
      </help>

      <nomatch>
         I'm sorry. I didn't get that.
         <reprompt/>
      </nomatch>

      <filled>
      <log>Recognized <value expr="fruit"/></log>
      <if cond="'repeat' == fruit">
         <clear namelist="fruit"/>
      <else/>
         you chose <value expr="fruit"/>
         <exit />
      </if>
      </filled>

      </field>
   </form>
</vxml>

Community Additions

ADD
Show:
© 2015 Microsoft