Page 1 of 1

Problem when add 1 to variable

Posted: Tue Aug 19, 2008 3:54 am
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.

IVR code to fix problem when adding 1 to variable

Posted: Tue Aug 19, 2008 9:30 am
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