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

String Comparison is not working higher then 10

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
josephg
Posts: 4
Joined: Thu Sep 22, 2016 10:51 am

String Comparison is not working higher then 10

Post by josephg »

Hi, I have the following code, If I press 0 or 1, then I'm prompter back with the value of "cc3Desc", However, if I press 10 (or anything higher then 10) then "cc3Desc", It sounds like it cannot do string comparison if there are 2 numbers

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
    
<vxml version="2.1"
      xmlns="http://www/w3/org/2001/VXML"
      xml:lang="en-US">
    <property name="inputmodes" value="dtmf" />
    <property name="documentmaxage" value="0s" />


    <var name="calledFrom" expr="'8455479080'" />
    <var name="calledTo" expr="'3999'" />
    <var name="sessionId" expr="'000025005;1478633348'" />
    <var name="co" expr="'3934'" />
    <var name="ee" expr="'9999'" />
    <var name="ssn" expr="'9999'" />
    <var name="cc1" expr="'CHSD'" />
    <var name="cc3Code" expr="" />
    <var name="cc3Desc" expr="" />
    <var name="punchType" expr="" />
    <form id="getCC3">
        <field name="CC3Response">
            <grammar type="application/srgs+xml" root="ROOT" mode="dtmf">
                <rule id="ROOT">
                    <one-of>
                        <item> 0 </item>
                            <item> 1 </item>
                            <item> 10 </item>
                            <item> 11 </item>
                            <item> 31 </item>
                    </one-of>
                </rule>
            </grammar>
            <prompt>
                Please enter the patient code.
            </prompt>
            <prompt>
                If you dont know the patient code then press zero.
            </prompt>
            
            <filled>
                <if cond="CC3Response == '0'">
                    <assign name="cc3Code" expr="'NA'" />
                    <assign name="cc3Desc" expr="'Unknown'" />
                        <elseif cond="CC3Response == '1'" />
                        <assign name="cc3Code" expr="'BALD'" />
                        <assign name="cc3Desc" expr="'Balduena John'" />
                        <elseif cond="CC3Response == '10'" />
                        <assign name="cc3Code" expr="'CLAS'" />
                        <assign name="cc3Desc" expr="'Classes Joe'" />
                        <elseif cond="CC3Response == '11'" />
                        <assign name="cc3Code" expr="'CLIN'" />
                        <assign name="cc3Desc" expr="'31 CLINIC'" />
                        
                </if>
                <prompt>
                    You Selected patient.
                    <value expr="cc3Desc" />
                </prompt>
                <prompt>
                    Thank You. Good Buy.
                </prompt>
                

            </filled>

        </field>
    </form>
</vxml>

    
    

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

Re: String Comparison is not working higher then 10

Post by support »

Hi,

What's occurring here is that when a match is processed for the values higher than a single digit, each digit is registered as a deparate dtmf input value, so the value of CC3Response for 10 is 1 0 and not 10, hence why your string comparison was not working. There are a few ways to work around this, but one way would be to strip out the spaces between digit input greater than 1 digit. Here's a sample doing just that. The value is logged before and after stripping the space so you can see the difference in values in the call log itself.

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
    
<vxml version="2.1"
      xmlns="http://www/w3/org/2001/VXML"
      xml:lang="en-US">
    <property name="inputmodes" value="dtmf" />
    <property name="documentmaxage" value="0s" />


    <var name="calledFrom" expr="'8455479080'" />
    <var name="calledTo" expr="'3999'" />
    <var name="sessionId" expr="'000025005;1478633348'" />
    <var name="co" expr="'3934'" />
    <var name="ee" expr="'9999'" />
    <var name="ssn" expr="'9999'" />
    <var name="cc1" expr="'CHSD'" />
    <var name="cc3Code" expr="" />
    <var name="cc3Desc" expr="" />
    <var name="punchType" expr="" />
    <form id="getCC3">
        <field name="CC3Response">
            <grammar type="application/srgs+xml" root="ROOT" mode="dtmf">
                <rule id="ROOT">
                    <one-of>
                        <item> 0 </item>
                        <item> 1 </item>
                        <item> 10 </item>
                        <item> 11 </item>
                        <item> 31 </item>
                    </one-of>
                </rule>
            </grammar>
            <prompt>
                Please enter the patient code.
            </prompt>
            <prompt>
                If you dont know the patient code then press zero.
            </prompt>
            
            <filled>
                <log><value expr="CC3Response"/></log>
                <assign name="CC3Response" expr="CC3Response.split(' ').join('')"/>
                <log><value expr="CC3Response"/></log>
                <if cond="CC3Response == 0">
                        <assign name="cc3Desc" expr="'Balduena John'" />
                <elseif cond="CC3Response == 1"/>
                        <assign name="cc3Desc" expr="'Someone Else'" />
                <elseif cond="CC3Response == 10"/>
                        <assign name="cc3Desc" expr="'Another Patient'" />
                <elseif cond="CC3Response == 11"/>
                        <assign name="cc3Desc" expr="'Yet Another Patient'" />
                <elseif cond="CC3Response == 31"/>
                        <assign name="cc3Desc" expr="'And Yet Another Patient'" />
                </if>
                <prompt>
                    You Selected patient.
                    <value expr="cc3Desc" />
                </prompt>
                <prompt>
                    Thank You. Good Buy.
                </prompt>
                

            </filled>

        </field>
    </form>
</vxml>
Hopefully thatrhelps, but let us know if you have any additional questions.

Regards,
Plum Support

josephg
Posts: 4
Joined: Thu Sep 22, 2016 10:51 am

Re: String Comparison is not working higher then 10

Post by josephg »

Thanks a lot, that helped

Post Reply