NumConvert Extension [Open Source]

NumConvert Is The Extension Which Converts Numbers To It’s Short Form Like 1234 to 1.2k+

Blocks

Capture

--------------------:warning::warning:Important :warning::warning:-----------------------

This Extension Currently Convert Numbers Which Are Less Than 2400. I Know This Is Not Useful Extension. I Have Created It For Learning Only. If Anyone Wants To Convert Numbers Which Are 2400+ Then You Can Use Alternative Extensions Or I Have Provided Source Code Of Extension Also. You Can Edit It As You Want…

com.technovedang.numconvert.aix (5.7 KB)

Source https://github.com/TechnoVedang/NumConvert-extension-for-ai2-kodular

16 Likes

Simple, Small.
But Useful.

1 Like

Thanks :heart_eyes: :heart_eyes:

A good example for me to learn. I am new to extension and I am trying to learn. Can I know if extension use JavaScript or Java?

1 Like

java.

1 Like

Thanks! :blush:

1 Like

You are Welcome

1 Like

that’s why i have given the source code. this type of extensions are good for learning

I looked at the source code… and I only can recommend to NOT learn from that… Sorry…
but I will add it into the extensions directory as an example, how NOT to do it…

 @SimpleFunction(description = "convert number")
    public String ConvertViews(int number){
        // 1
        int a = 999;
        int b = 1099;
        int c = 1200;
        int d = 1299;
        int e = 1300;
        int f = 1399;
        int g = 1400;
        int h = 1499;
        int i = 1500;
        int j = 1599;
        int k = 1600;
        int l = 1699;
        int m = 1700;
        int n = 1799;
        int o = 1800;
        int p = 1899;
        int q = 1900;
        int r = 1999;
        int s = 2000;
        int t = 2099;
        int u = 2100;
        int v = 2199;
        int w = 2200;
        int x = 2299;
        int y = 2300;
        int z = 2399;
        /* 2 */
        int aa = 2400;
        int bb = 2499;
        int cc = 2500;
        int dd = 2599;
        int ee = 2600;
        int ff = 2699;
        int gg = 2700;
        int hh = 2799;
        int ii = 2800;
        int jj = 2899;
        int kk = 2900;
        int ll = 2999;
        int mm = 3000;
        int nn = 3099;
        int oo = 3100;
        int pp = 3199;
        int qq = 3200;
        int rr = 3299;
        int ss = 3300;
        int tt = 3399;
        int uu = 3400;
        int vv = 3499;
        int ww = 3500;
        int xx = 3599;
        int yy = 3600;
        int zz = 3699;

        int aaa = 3700;
        int bbb = 3799;
        int ccc = 3800;
        int ddd = 3899;
        int eee = 3900;
        int fff = 3999;
        int ggg = 4000;
        int hhh = 4099;
        int iii = 4100;
        int jjj = 4199;
        int kkk = 4200;
        int lll = 4299;
        int mmm = 4300;
        int nnn = 4399;
        int ooo = 4400;
        int ppp = 4499;
        int qqq = 4500;
        int rrr = 4599;
        int sss = 4600;
        int ttt = 4699;
        int uuu = 4700;
        int vvv = 4799;
        int www = 4800;
        int xxy = 4899;
        int yyy = 4900;
        int zzz = 4999;

        int aaaa= 5000;


        if(number < b && number > a){
            return "1k+";
        } else if (number < a){
            return "number";
        } else if(number > b && number < c){
            return "1.1k+";
        }else if(number > b && number < d){
            return "1.2k+";
        }else if(number > d && number < g){
            return "1.3k+";
        }else if (number > f && number < i){
            return "1.4k+";
        }else if(number > h && number < k){
            return "1.5k+";
        }else if(number > j && number < m){
            return "1.6k+";
        }else if(number > l && number < o){
            return "1.7k+";
        }else if(number > n && number < q){
            return "1.8k+";
        }else if(number > p && number < s){
            return "1.9k+";
        }else if (number > r && number < u){
            return "2k+";
        }else if(number > t && number < w){
            return "2.1k+";
        }else if(number > v && number < y){
            return "2.2k+";
        }else if(number > x && number < aa){
            return "2.3k+";
        }else {
            return "number > 2.3k";
        }

    }

DRY - Don’t repeat yourself

Taifun

8 Likes

you might want to implement this solution or one of the others in this page


Taifun

3 Likes

Thanks taifun. I will try your solution

I am at too beggining level of java. So i started to learn it on youtube. After watching some tutorials i started to practice it on IDE and therefore i got this idea and i also converted it into aix

1 Like