Results 1 to 9 of 9

Thread: WriteLn IntToStr with comma?

  1. #1
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default WriteLn IntToStr with comma?

    Got this
    Simba Code:
    Writeln('| Gained '+IntToStr(Round(XPRate))+' Experience/Hour' + PadL('|', 11) );

    I want it to place commas in the correct places when the number requires it.
    Last edited by YoHoJo; 11-16-2011 at 11:00 PM.

  2. #2
    Join Date
    Aug 2009
    Location
    Nova Scotia, Canada
    Posts
    604
    Mentioned
    0 Post(s)
    Quoted
    56 Post(s)

    Default

    Code:
    Format('%4.0n', [XPRate])
    There is another way, but can't for the life of me think of it off the top of my head.
    Never ever approach a computer saying or even thinking "I will just do this quickly".

  3. #3
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Whoa, what's the "'%4.0n'" about?

    Simba Code:
    Writeln(Format('%4.0n', [9000])   )

    Doesn't compile.
    Error: Exception: Invalid argument index in format "" at line 4

  4. #4
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    http://villavu.com/forum/showthread.php?t=47409

    For format, by the way. But that doesn't really explain what you need. I don't know if there's a function for this already, but to add commas is pretty simple. Can't explain now, but if you get the length of a string of numbers, I think you can figure it out.

  5. #5
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Simba Code:
    {*******************************************************************************
    function GroupDigits(n: integer; token: String): String;
    By: PriSoner and Nava2
    Description: Formats an integer into groups of 3 seperated by `token' and
                 returns a formatted string (i.e 1234567 would become 1,234,567)
    *******************************************************************************}

    Thanks again you goodfornothin's

  6. #6
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    Use Format...but for some reason I can't pass %n which is the number format constant.

    Edit: It seems you can't pass many of the format constants.... Only ones that worked for me were %d %u %x
    Last edited by mormonman; 11-16-2011 at 11:48 PM.

  7. #7
    Join Date
    Aug 2009
    Location
    Nova Scotia, Canada
    Posts
    604
    Mentioned
    0 Post(s)
    Quoted
    56 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Simba Code:
    {*******************************************************************************
    function GroupDigits(n: integer; token: String): String;
    By: PriSoner and Nava2
    Description: Formats an integer into groups of 3 seperated by `token' and
                 returns a formatted string (i.e 1234567 would become 1,234,567)
    *******************************************************************************}

    Thanks again you goodfornothin's
    That's what I was trying to think of. No way would it come to me.
    Never ever approach a computer saying or even thinking "I will just do this quickly".

  8. #8
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Mormonman, file a bug report.

    YoHoJo.. just use the search function, or check the docs before posting.. :/
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  9. #9
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    I did both. Didn't see it anywhere.
    Then I looked though MSI and found the answer.
    LEME make threads if I want to, you guys are faster/smarter (normally)!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •