Page 1 of 1

Increment a varibale by one for three times & exit at th

Posted: Tue Dec 12, 2006 10:27 am
by awaneeshp
Hi,

I have a situation where in i need to increment a varibale in else condition (i.e. non matching condition other than mentioned in if loop). And need to exit after the third attempt without using the NoMatch event.

If(cond== 1)

else if (cond==2)

else

var = var +1

If var =3 then exit

Can you suggest some VXML syntax to achieve this?

Thanks,
-Awaneesh

"cond" variable could lead to IVR code readability

Posted: Tue Dec 12, 2006 12:51 pm
by support
Some combination of the IVR tags, <if>, <elseif>, <else>, and <assign> should work for you.

I also would NOT use "cond" as a variable name since it's a very common VXML attribute name. It's not reserved per se, but it could lead to IVR code readability problems for you down the road.

Your IVR pseudocode would look something like this:

Code: Select all

<if cond="somevar==1">
  <!-- DO SOMETHING -->
<elseif cond="somevar==2"/>
  <!-- DO SOMETHING ELSE -->
<else/>
  <assign name="anothervar" expr="anothervar+1"/>
  <if cond="anothervar==3">
    <exit/>
  </if>
</if>
You will find a great deal of helpful information and IVR examples in Plum's IVR Programmers Reference Manual as well as the VoiceXML spec itself.