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

Problem when add 1 to variable

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
soso
Posts: 62
Joined: Tue Apr 22, 2008 8:11 am

Problem when add 1 to variable

Post by soso »

Hi,

Can you explain me why the result is '01' when add +1 to my variable?

I've this variable:

Code: Select all

<var name="essai" assign="0" />
After procedure:

Code: Select all

<assign name="essai" expr="essai+1"/>
And result is '01' instead '1'?

Why?

Thansk by advance.

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

IVR code to fix problem when adding 1 to variable

Post by support »

Hi,

For your variable

variable:

Code: Select all

<var name="essai" assign="0" />
did you mean to write this?

Code: Select all

<var name="essai" expr="0" />
Also, are you using any single quotes around the 0? If you are, then this would cause 01 to be returned since it would be adding 1 to the string 0.

You can use the following IVR code example to help you with this IVR issue:

testvar.php:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>

<vxml version="2.0">
  <form>
    <var name="test_var" expr="0"/>
    <block>
      <assign name="test_var" expr="test_var+1"/>
    </block>
    <block>
      <prompt>
        The test variable is set to <value expr="test_var"/>.
      </prompt>
    </block>
  </form>
</vxml>
Regards,
Plum Support

Post Reply