Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

problem with dot and comma- number format

Tom24Tom24 Posts: 22Member, PRO

Hello Guys,

I am working on an App (or part of an app) with some calculations.

And the result is a large number.
The calculation works perfectly, but i have a problem with the format of the number.

I want to show the number like this: 1.545,45

But in Gamesald it looks like: 1545.45

The system language of my Mac is set on German, and also the system format is set like 1.545,45

is there a way to change the format?




  • NNterprisesNNterprises Posts: 387Member, PRO

    So you want it to look like 1.545,45?

    Not like 1,545.45?

  • Tom24Tom24 Posts: 22Member, PRO
    edited July 2016

    yes i want it to look like 1.545,45 because i want to show a price (€) and the Format in Germany (or better in Austria) is like this. i think in other countries the format is like gamesalad shows it

  • NNterprisesNNterprises Posts: 387Member, PRO
    edited July 2016

    Cool I didn't know that...

    If you want it like you suggested you will have to do a display text as:
    if x=1545.45


    Its pretty much saying:
    Show a 1, then a period, then the rest without the decimal, then a comma, then the decimal place

    My ROUND may be incorrect, it may have to be ROUNDTO but I'm not sure and rushing

  • Tom24Tom24 Posts: 22Member, PRO

    Ok Thank's i will try this!
    But i am not sure if this work, because the numer (x) changes between 0 and maybe 9999999

    because the app calculates the vehicle-insurance tax depending on the input

    (i try yours maybe with a rule when X is > than 1000 or so..)

    I'll come back if it works


  • Tom24Tom24 Posts: 22Member, PRO

    Unfortunately this does not work.
    it is sad that it's not possible to adjust the formatting easier in gamesalad :|

  • ArmellineArmelline Posts: 4,826Member, PRO

    There's a few ways to add the commas. But the difficulty doing this isn't GameSalad's fault. Most programming languages don't build in a way to format text like this directly, and Lua, the language powering GameSalad, doesn't either. However, you can use a little Lua magic to get the effect you want in GameSalad.

    Here's a demo of some rather complicated ways of getting the result you want. Should work with numbers in text attributes, reals and integers, with decimals places, and allows the swapping of . and ,

    There's probably an easier way to do this, but that's what I did. Lets you display a number without needing rules or other attributes etc.

  • Tom24Tom24 Posts: 22Member, PRO

    :o:o:o OMG the expression editor looks crazy!
    Thanks for your help!

    how do you get the idea of such a big formulaic?

    wow..I have to try your formula

    but i think one of my problems with the format ist, that the number changes constantly between 2 and some thousand, so the format also has to change

    The number i change is a "real" attribute and when i change the number you use for your Demo with display a real number to a small number like 50 the format is also not correctly

    I think my head is too small to understand your formula :D

    but i will make some test with it!


  • Tom24Tom24 Posts: 22Member, PRO


    Great! Now i implemented your formula correctly into my project :)

    except for a few little things it works very well :) Thanks

    maybe you have an idea how I can fix the little things:

    when the number ist zero it looks like= 0,0. (i mean the dot at least- is not so important)
    numbers between 1 and 99,99 looks perfect :)
    numbers over 100 looks like= .455,98 (maybe you have an idea how i can remove the dot in front of the number when the number is over 100 and under 1.000)

    your formula helps me a lot! thanks for that

  • ArmellineArmelline Posts: 4,826Member, PRO

    Hmm, I'll take a look at why it's not displaying small numbers without decimals correctly.

  • Tom24Tom24 Posts: 22Member, PRO

    @Armelline no the small numbers are not the problem! I wrote a little too fast :D

    Its only the dot in front of the number when the number is between 100 and 1000

    but with your formula I'm already much further than with the formulas I tried by myself :p

  • ArmellineArmelline Posts: 4,826Member, PRO

    After you said that I experimented a bit and found some problems with small numbers. I'm too swamped right now to fix it, but it's going to bug me until I do so I'll definitely get it fixed asap!

Sign In or Register to comment.