We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

How can I return an array object?

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
jcanter
Posts: 47
Joined: Thu Jun 19, 2003 8:54 am

How can I return an array object?

Post 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>

jcanter
Posts: 47
Joined: Thu Jun 19, 2003 8:54 am

Post by jcanter »

I think I found my own answer to this. I think I had a scoping problem of some sort.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR example of an array returned from a subdialog

Post 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'...

Post Reply