# Numbers to string

**URL:** <https://community.glideapps.com/t/numbers-to-string/39879>\
**Category:** Ask for Help\
**Created:** [March 20, 2022, 7:36pm UTC](https://community.glideapps.com/t/numbers-to-string/39879 "2022-03-20T19:36:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yasin\_Hassanien](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/yasin_hassanien/32/9042_2.png) [@Yasin\_Hassanien](https://community.glideapps.com/u/Yasin_Hassanien)\
**Post date:** [March 20, 2022, 7:36pm UTC](https://community.glideapps.com/t/numbers-to-string/39879/1 "2022-03-20T19:36:18Z")

</div>

Does anyone have an idea to use a free api for numbers to string with no limits or a javascript that works ?

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [March 20, 2022, 10:07pm UTC](https://community.glideapps.com/t/numbers-to-string/39879/2 "2022-03-20T22:07:49Z")

</div>

What are you trying to do? A template column can convert a number to a string. You could use javascript too, but I guess it would be better to understand what you are attempting.

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [March 20, 2022, 10:09pm UTC](https://community.glideapps.com/t/numbers-to-string/39879/3 "2022-03-20T22:09:51Z")

</div>

number.toString()

---

<div class="post-metadata">

**Author:** ![Yasin\_Hassanien](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/yasin_hassanien/32/9042_2.png) [@Yasin\_Hassanien](https://community.glideapps.com/u/Yasin_Hassanien)\
**Post date:** [March 20, 2022, 10:57pm UTC](https://community.glideapps.com/t/numbers-to-string/39879/4 "2022-03-20T22:57:20Z")

</div>

How to achive that?

---

<div class="post-metadata">

**Author:** ![Yasin\_Hassanien](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/yasin_hassanien/32/9042_2.png) [@Yasin\_Hassanien](https://community.glideapps.com/u/Yasin_Hassanien)\
**Post date:** [March 20, 2022, 10:57pm UTC](https://community.glideapps.com/t/numbers-to-string/39879/5 "2022-03-20T22:57:48Z")

</div>

Am generating a document where it has to mention the Number of cheque amount

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [March 20, 2022, 11:01pm UTC](https://community.glideapps.com/t/numbers-to-string/39879/6 "2022-03-20T23:01:43Z")

</div>

Ok. I thought you meant just converting a number to a string. “1000.00” converted from numeric to a string still is “1000.00”. But as I understand it, you actually want it to say “One Thousand” or something like that?

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [March 20, 2022, 11:12pm UTC](https://community.glideapps.com/t/numbers-to-string/39879/7 "2022-03-20T23:12:24Z")

</div>

I did a quick google search and found something. Try this in a javascript column and point your P1 parameter to the column that contains the number.

```auto
// System for American Numbering 
var th_val = ['', 'thousand', 'million', 'billion', 'trillion'];
// System for uncomment this line for Number of English 
// var th_val = ['','thousand','million', 'milliard','billion'];
 
var dg_val = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
var tn_val = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'];
var tw_val = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'];
function toWords(s) {
  s = s.toString();
    s = s.replace(/[\,]/g, '');
    if (s != parseFloat(s))
        return 'not a number ';
    var x_val = s.indexOf('.');
    if (x_val == -1)
        x_val = s.length;
    if (x_val > 15)
        return 'too big';
    var n_val = s.split('');
    var str_val = '';
    var sk_val = 0;
    for (var i = 0; i < x_val; i++) {
        if ((x_val - i) % 3 == 2) {
            if (n_val[i] == '1') {
                str_val += tn_val[Number(n_val[i + 1])] + ' ';
                i++;
                sk_val = 1;
            } else if (n_val[i] != 0) {
                str_val += tw_val[n_val[i] - 2] + ' ';
                sk_val = 1;
            }
        } else if (n_val[i] != 0) {
            str_val += dg_val[n_val[i]] + ' ';
            if ((x_val - i) % 3 == 0)
                str_val += 'hundred ';
            sk_val = 1;
        }
        if ((x_val - i) % 3 == 1) {
            if (sk_val)
                str_val += th_val[(x_val - i - 1) / 3] + ' ';
            sk_val = 0;
        }
    }
    if (x_val != s.length) {
        var y_val = s.length;
        str_val += 'point ';
        for (var i = x_val + 1; i < y_val; i++)
            str_val += dg_val[n_val[i]] + ' ';
    }
    return str_val.replace(/\s+/g, ' ');
}

return toWords(p1);

```

---

<div class="post-metadata">

**Author:** ![Yasin\_Hassanien](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/yasin_hassanien/32/9042_2.png) [@Yasin\_Hassanien](https://community.glideapps.com/u/Yasin_Hassanien)\
**Post date:** [March 20, 2022, 11:52pm UTC](https://community.glideapps.com/t/numbers-to-string/39879/8 "2022-03-20T23:52:39Z")

</div>

Thanks Jeff

Wannted to know if this is normal

 ![16478203335978537189276633922392](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/c/cce75cc7a6968f5e68cd8fcbda6f73065126823d.jpeg)

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [March 21, 2022, 12:08am UTC](https://community.glideapps.com/t/numbers-to-string/39879/9 "2022-03-21T00:08:33Z")

</div>

A lot of times, those errors seem to usually be a step behind and actually show a previous error.

But in this case it also could be failing if an empty (null) parameter is being passed in. In that case, add this to the beginning of the toWords function. That way it will bounce out, and return a blank, before encountering any error due to a null parameter.

```auto
if (s == null) {
return '';
}

```

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [March 22, 2022, 12:09am UTC](https://community.glideapps.com/t/numbers-to-string/39879/10 "2022-03-22T00:09:20Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
