Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Here's a new one...
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Thu 06 Oct 2005 10:53 PM (UTC) |
Message
| I want to insert comma's into a string of numbers.
So 56738593 becomes 56,738,593
Any idea's? | Top |
|
Posted by
| Shadowfyr
USA (1,790 posts) Bio
|
Date
| Reply #1 on Fri 07 Oct 2005 03:50 AM (UTC) |
Message
| Depends on the language and if you mean numbers recieved from the mud. Using an 'omit from output' trigger and script you can replace the line (sans any color information, which gets complicated to duplicate). As for inserting the commas:
VBScript:
FormatNumber(Expression [,NumDec[,IncLead[,UseParens[,Group]]])
In other words:
note FormatNumber("-0.4567",2,-1,-1,-1)
note FormatNumber("12245235",0,0,0,-1)
produces:
[-0.45]
12,245,235
NumDec = number of digits following the decimal.
IncLead = Show the '0' in cases where it is something like 0.1323
UseParens = show [] around negative numbers (common in spread sheets to see them easier).
Group = Add commas.
The IncLead, UseParens and Group settings are -1 = on, 0 = off, -2 = use default.
I am sure other languages have something like this as well, but not sure what they are. There are also some limitations to using omit from output and 'when' it displays. I believe the main one is that if you use 'send to script', then the commands to display text will be ignored. For example, if you have the following trigger and script:
<triggers>
<trigger
enabled="y"
match="test"
omit_from_output="y"
script="test22"
send_to="12"
sequence="100"
>
<send>note "test"</send>
</trigger>
</triggers>
------
script: set in Scripting->Scripts->Script File
------
sub test22(name, output, wildcards)
note "test 2"
end sub
When the word 'test' is recieved, you *won't* see the word 'test' repeated 'in' the trigger with 'send to script', but you *will* see 'test 2' appear when the same trigger calls the subroutine 'test22'. This is due to how Mushclient handles things in the 'send' field when using 'omit from output'. | Top |
|
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #2 on Fri 07 Oct 2005 07:40 AM (UTC) Amended on Wed 12 Oct 2005 08:16 AM (UTC) by David Berthiaume
|
Message
| That FormatNumber was exactly what I was looking for, Thanks.
All that other stuff you posted about, I have no idea what you're talking about. That's all old news to me, I know what you're talking about. I rarely put scripts in a script file anymore. Easier to just write it all out in aliases and triggers. I dont have anything very large, my biggest script is all Info stuff, but the actual data manipulation is minor.
Edit: After reading your post again, I see what you're talking about. I wasn't thinking of using it to omit from output and stuff. I wanted to add numbers to my InfoBar script I'm in the middle of writing for this mud. So yeah, I just needed to add comma's | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
15,749 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top