Here's a new one...

Posted by David Berthiaume on Thu 06 Oct 2005 10:53 PM — 3 posts, 19,635 views.

#0
I want to insert comma's into a string of numbers.

So 56738593 becomes 56,738,593

Any idea's?
USA #1
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'.
#2
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