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

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

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
awaneeshp
Posts: 29
Joined: Fri Nov 17, 2006 1:48 am

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

Post 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

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

"cond" variable could lead to IVR code readability

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

Post Reply