Page 1 of 1

How can I return an array object?

Posted: Fri Sep 05, 2003 1:45 pm
by jcanter
Can I return an array through the return tag somehow? For example:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
<form>
<var name="code" expr="1"/>
  <block>
<script>
  PAYMENT = new Array(5)

  PAYMENT[0] = '.00'
  PAYMENT[1] = '.00'
  PAYMENT[2] = '2.00'
  PAYMENT[3] = '2.00'
  PAYMENT[4] = '.00'
</script>
    <return namelist="code PAYMENT"/>
  </block>
</form>
</vxml>

Posted: Mon Sep 08, 2003 2:03 pm
by jcanter
I think I found my own answer to this. I think I had a scoping problem of some sort.

IVR example of an array returned from a subdialog

Posted: Tue Sep 09, 2003 12:50 pm
by support
Here's an IVR example of an array returned from a <subdialog>:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0">
        <form id="caller">
                <block>
                        <prompt>Going to jump.</prompt>
                </block>
                <subdialog name="subd" src="#callee">
                        <param name="myid" expr="'caller form'"/>
                </subdialog>
                <block>
                        <prompt>
                                Jumped back. The array contains:
                                <value expr="subd.myarray[0]"/>
                                <value expr="subd.myarray[1]"/>
                                <value expr="subd.myarray[2]"/>
                                <value expr="subd.myarray[3]"/>
                        </prompt>
                </block>
        </form>
        <form id="callee">
                <var name="myid"/>
                <var name="myarray"/>
                <script>
                        myarray = new Array(4);
                        myarray[0] = 'one';
                        myarray[1] = 'two';
                        myarray[2] = 'three';
                        myarray[3] = 'four';
                </script>
                <block>
                        <prompt>Jumped from <value expr="myid"/>.</prompt>
                        <return namelist="myarray"/>
                </block>
        </form>
</vxml>
The output from the above IVR script is:
Going to jump...
Jumped from 'caller form'...
Jumped back. The array contains 'one two three four'...