SRL Archive - OSR Help

WriteLn IntToStr with comma?


YoHoJo

2011-11-16 17:47:57

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

I want it to place commas in the correct places when the number requires it.

Bixby Sayz

2011-11-16 18:30:43

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.

YoHoJo

2011-11-16 18:31:35

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

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

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

i luffs yeww

2011-11-16 18:43:22

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. :)

YoHoJo

2011-11-16 18:45:30

{*******************************************************************************
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

mormonman

2011-11-16 18:46:11

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

Bixby Sayz

2011-11-16 20:05:39

From: YoHoJo
{*******************************************************************************
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.

Nava2

2011-11-16 20:06:38

Mormonman, file a bug report. :)

YoHoJo.. just use the search function, or check the docs before posting.. :/

YoHoJo

2011-11-16 20:07:56

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)!