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

large int converting to exponent

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
ljnftw
Posts: 6
Joined: Mon Oct 30, 2017 10:47 am

large int converting to exponent

Post by ljnftw »

I am attempting to receive a large response from the caller. It appears to be received properly but at some point either there or in the JavaScript code is is being expressed exponentially.

Below is the snip of the code where I receive the number then add to an XML packet.

Example:
user enters 12345678901234567890123
JavaScript converts to 1.2345678901234567e+22

Obviously this does not work. I am new to VXML and JavaScript (should be obvious :shock: )

Code snip as follows:

...

<field name="BigNum" type="digits?minlength=15">
<prompt>
Please enter all the numbers that appear on your document, followed by the pound key.
</prompt>
<filled>
<assign name="obj.BigNum" expr="BigNum"/>
</filled>
</field>


...

<form id="verifyDocument">
<var name="obj"/>

<script>
<![CDATA[
function Getdocument(obj)
{
var document = ("<>" +
...
"<>" + obj.BigNum + "</> " +
...
"</>"
);

return document;
}
]]>
</script>

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

Re: large int converting to exponent

Post by support »

Hello!

I'm happy to help. I see some lines code are missing, are you modifying the caller's response mathematically or parsing it into an integer?

Regards,
Plum Support

ljnftw
Posts: 6
Joined: Mon Oct 30, 2017 10:47 am

Re: large int converting to exponent

Post by ljnftw »

support wrote:Hello!

I'm happy to help. I see some lines code are missing, are you modifying the caller's response mathematically or parsing it into an integer?

Regards,
Plum Support
Yes I have left out all code that does not touch the BigNum.

It is a user entered preassigned document number. No modification or parsing of anything.

I really want it received as a string that I am including into an XML packet that will query a database.

It is entered as dtmf. I need the value to match EXACTLY. No Exponentiation and no dropping leading zeros.

I am not totally positive if the exponentiation is occurring in the VXML or when I call the JavaScript code.

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

Re: large int converting to exponent

Post by support »

Hello,

The code listed below functions to your specifications given the information provided, the variable ("BigNum") received from the VXML will be of type string.

I removed the "obj" variable, if you'd like to create a JavaScript object using the "obj" variable you'll need to define it inside a <script> tag and assign object properties as you would in any other JS environment.

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
    <property name="inputmodes" value="dtmf"/>
    <form>
        <field name="BigNum" type="digits?minlength=15">
             <prompt>
                   Please enter all the numbers that appear on your document, followed by the pound key.
             </prompt>
             <filled> 
                <assign name="BigNum" expr="BigNum"/>
             </filled>
        </field>
        <block>
             <script>
                 <![CDATA[
                     function Getdocument(){ 
                         var document = "<>" + "<>" + BigNum + "</>" + "</>";
                         return document;
                     }
                 ]]>
             </script>
             <prompt> value is <value expr="Getdocument()"/> </prompt>
        </block>
    </form>
</vxml>

ljnftw
Posts: 6
Joined: Mon Oct 30, 2017 10:47 am

Re: large int converting to exponent

Post by ljnftw »

support wrote:Hello,

The code listed below functions to your specifications given the information provided, the variable ("BigNum") received from the VXML will be of type string.

I removed the "obj" variable, if you'd like to create a JavaScript object using the "obj" variable you'll need to define it inside a <script> tag and assign object properties as you would in any other JS environment.

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
    <property name="inputmodes" value="dtmf"/>
    <form>
        <field name="BigNum" type="digits?minlength=15">
             <prompt>
                   Please enter all the numbers that appear on your document, followed by the pound key.
             </prompt>
             <filled> 
                <assign name="BigNum" expr="BigNum"/>
             </filled>
        </field>
        <block>
             <script>
                 <![CDATA[
                     function Getdocument(){ 
                         var document = "<>" + "<>" + BigNum + "</>" + "</>";
                         return document;
                     }
                 ]]>
             </script>
             <prompt> value is <value expr="Getdocument()"/> </prompt>
        </block>
    </form>
</vxml>
Thanks. It was defined outside the script.

I actually found what appears to be a simpler solution in the JavaScript. Concatenating a null string seem to be working.

I do not see what your solution did that mine did not other than pull BigNum out as it' own variable which would then have to be added BACK into the document variable so it could be processed.

<script>
<![CDATA[
function Getdocument(obj)
{
var document = ("<>" +
...
"<>" + obj.BigNum + '' + "</> " +
...
"</>"
);

Post Reply