Page 1 of 1

large int converting to exponent

Posted: Fri Jan 05, 2018 3:28 pm
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>

Re: large int converting to exponent

Posted: Mon Jan 08, 2018 11:15 am
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

Re: large int converting to exponent

Posted: Mon Jan 08, 2018 11:36 am
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.

Re: large int converting to exponent

Posted: Mon Jan 08, 2018 2:23 pm
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>

Re: large int converting to exponent

Posted: Tue Jan 09, 2018 9:55 am
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 + '' + "</> " +
...
"</>"
);