|
DeathDealer Adept
Joined: 20 Jul 2004 Posts: 268
|
Posted: Thu Mar 31, 2005 5:26 pm
#echo %format @vars **SOLVED** |
Code: |
#VAR ARDay {123456789}
#echo %ansi(high,green)Today%format("&17.0n", @ARDay)
Today 123,456,792
#echo @ARDay
123456789 |
Why is the result in the %format different (and incorrect), than the plain echo (which IS correct)?
The %formatted part is correct up until 12345678.
Just to check i did 999999999 and got 1,000,000,000 as the result.
err...yeah... |
|
_________________
Last edited by DeathDealer on Fri Apr 01, 2005 7:06 pm; edited 1 time in total |
|
|
|
Maelstrom Apprentice
Joined: 10 Feb 2005 Posts: 158
|
Posted: Thu Mar 31, 2005 5:58 pm |
Looks like an internal parsing error. The variable has nothing to do with it... same results using:
#echo %format("&9.0n","123456789") |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Thu Mar 31, 2005 11:12 pm |
Internally it is converted into a real number. Then formatted out. I believe the system used for real numbers is provided by MS through a COM interface. It is quite sad though that it can't even be accurate to 9 digits.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
DeathDealer Adept
Joined: 20 Jul 2004 Posts: 268
|
Posted: Fri Apr 01, 2005 12:00 am |
well, given that I am trying to make a counter, and eventually, i'll prolly need that much, how would i go about making a counter in bits?
like
@artodayhundreds
@artodaythousands
@artodaymillions
@artodaybillions
i have think it would be something like on the trigger do a +1 to the hundreds, but how once i get to 999 to i tell it to reset to 000 and add +1 to the thousands.
tho alternately, since it's already known that once ya hit 9 numbers it goes bonkers, so i guess i could have a:
@artodayhunthou
@artodaymillibilli
But would still need to know how to once it gets to 999999 to roll over and add 1 to the millibilli var.
something like #if @artodayhunthou == 1000000 then @artodayhunthou = 000000;#add @artodaymillibilli 1
but somehow (and i havent tried it and cant for a lil while) i don't think the 000000 will stay as that but will be set to 0, kinda screwing up the report in the process. |
|
_________________
|
|
|
|
Maelstrom Apprentice
Joined: 10 Feb 2005 Posts: 158
|
Posted: Fri Apr 01, 2005 3:08 am |
Thats too complicated. What you need is not a different method to store numbers but a better format function.
Well this is going to look awful if your not used to real regular expressions but this regex will take a number and add commas...
#function addcommas {%subregex(%1,"(\d(1,3)?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))","%%1,")}
Use:
#echo @addcommas(@ARDay)
How do you like them apples... |
|
|
|
DeathDealer Adept
Joined: 20 Jul 2004 Posts: 268
|
Posted: Fri Apr 01, 2005 3:31 am |
I like apples, but unless i can get that into this the %format part for the padding that I need sadly the apples got worms in them
|
|
_________________
|
|
|
|
DeathDealer Adept
Joined: 20 Jul 2004 Posts: 268
|
Posted: Fri Apr 01, 2005 4:31 am |
well, checked to see if having more than one 0 in a var would display correctly.
Yes AND no..
Code: |
#VAR ARDay {000000}
#echo %ansi(high,green)Today%format("&17.0n", @ARDay)
Result:
Today 0
BOOO!!!
#VAR ARDay {000000}
#function addcommas {%subregex(%1,"(\d(1,3)?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))","%%1,")}
#echo @addcommas(@ARDay)
Result:
000,000
YAY!!! |
Now if I could have them meet half way and let them work together so that i could get
that would be exactly what I am looking for.
Note: the 000000 is only there to illustrate what i need. coulda just as easily been 999999. just wanted to show that I need the padding. |
|
_________________
|
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Fri Apr 01, 2005 10:32 am |
Adding spcaes for padding is easy:
#FUNCTION padleft {%concat(%repeat(%3,%eval(%2-%len(%1))),%1)}
Usage: @padleft(string,"pad_character",int_width)
The only forseeable problem is if the string contains commas but is not properly quoted it would throw things off. I believe the %subregex will return a properly quoted string though. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
DeathDealer Adept
Joined: 20 Jul 2004 Posts: 268
|
Posted: Fri Apr 01, 2005 5:22 pm |
eeerrr....
k, lemme start from the beginning.
I am making a battle reporter based off of megamog75's Annual Reporter.
Here is what the layout IDEALLY will look like
Code: |
Kills| Backstabs Ratio| Vorpals| Terminates| Deathblows
----------------------|---------------------|--------------|--------------|--------------
Today 123,456,792| 123,456,792 99%| 123,456,792| 123,456,792| 123,456,792
This Mort 123,456,792| 123,456,792 99%| 123,456,792| 123,456,792| 123,456,792
Last Mort 123,456,792| 123,456,792 99%| 123,456,792| 123,456,792| 123,456,792
This Tier 123,456,792| 123,456,792 99%| 123,456,792| 123,456,792| 123,456,792
Last Tier 123,456,792| 123,456,792 99%| 123,456,792| 123,456,792| 123,456,792
In all 123,456,792| 123,456,792 99%| 123,456,792| 123,456,792| 123,456,792
----------------------|---------------------|--------------|--------------|--------------
#VAR ARDay {123456789}
|
Now as can be seen, the var does not have commas, and the report says that it's 123,456,792 because of some screwy comma problem with windows or whatever.
So I need padded commas :-)
Vijilante i tried yours
#VAR ARDay {123456789}
#FUNCTION padleft {%concat(%repeat(%3,%eval(%2-%len(%1))),%1)}
#echo @padleft(@ARDay," ",9)
result:
123456789
err...no spaces...unless i misunderstood something. But either way since it dont do comma's it won't help me. unless i gotta have a function do a function on a var... |
|
_________________
|
|
|
|
Maelstrom Apprentice
Joined: 10 Feb 2005 Posts: 158
|
Posted: Fri Apr 01, 2005 5:47 pm |
Hey DeathDealer, yeah your missing a couple of things. Vijilante meant you to combine my comma number function with his padding function...
And since there are 9 numbers in 123456789 and you specified the width as 9 there was no padding =) (I think)
Try this?
@padleft(@addcommas(@ARDay)," ",17) |
|
|
|
DeathDealer Adept
Joined: 20 Jul 2004 Posts: 268
|
Posted: Fri Apr 01, 2005 5:53 pm |
#VAR ARDay {123456789}
#function addcommas {%subregex(%1,"(\d(1,3)?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))","%%1,")}
#FUNCTION padleft {%concat(%repeat(%3,%eval(%2-%len(%1))),%1)}
#echo @padleft(@addcommas(@ARDay)," ",17)
result:
123456789
still no spaces, and not even any commas :(
#echo @padleft("@addcommas(@ARDay)"," ",17)
result:
123,456,789
closer, but still no spaces...actually, no it's not closer cause it's only doing what the addcommas function does :-)
btw: I had tried Vi's one by itself with 20 rather than 9 as well. there were still no spaces. |
|
_________________
Last edited by DeathDealer on Fri Apr 01, 2005 6:08 pm; edited 2 times in total |
|
|
|
Maelstrom Apprentice
Joined: 10 Feb 2005 Posts: 158
|
Posted: Fri Apr 01, 2005 5:59 pm |
Hmm, ill work on it. Im sure mine can be modified for what you want... lemme poke at it
|
|
|
|
DeathDealer Adept
Joined: 20 Jul 2004 Posts: 268
|
Posted: Fri Apr 01, 2005 6:11 pm |
Thanks :-)
Starting to think, that going with the hunthou and millibilli route is gonna be easier...
Gonna try something. See if putting your addcommas into a ANOTHER var and have THAT display in my report works.
I'll post if it works :-) if it dont then i wont post cause my monitor will have a fist sized hole in the screen. |
|
_________________
|
|
|
|
Maelstrom Apprentice
Joined: 10 Feb 2005 Posts: 158
|
Posted: Fri Apr 01, 2005 6:14 pm |
Ok I did some testing... replace Vijilantes padleft function with this:
%concat(%repeat(" ",%eval(%3-%len(%1))),%1)
Seems the " " in the function call is getting stipped before it reaches the function so its padding with nothing...
and use:
#echo @padleft("@addcommas(@ARDay)"," ",17) |
|
|
|
DeathDealer Adept
Joined: 20 Jul 2004 Posts: 268
|
Posted: Fri Apr 01, 2005 6:56 pm |
YOU THE MEN Maelstrom and Vijilante!!
Works perfect!
*HUGE HUGS* |
|
_________________
|
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|