I'm sure I saw a thread about this somewhere here ages ago, but can't seem to find it.. I'm wondering if it's possible to insert commas into a large numerical value when you want to send it as a tell to the world. I found a thread on how to strip the commas from a number, but I'm wanting to do the opposite if it's not too much of a mission to do.
basically if i have a variable named 'valueX' with a value of say 50000000, and that number is picked up from the mud by a trigger (the mud does not include commas), I'd then like to be able to
world.send "grouptell " & valueX & " points"
but somehow have that value 50000000 show as 50,000,000
Is this a major mission to do? It's not really important, just an aesthetic thing, but if it's not too hard to do, I'd like to know how. :)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctformatnumber.asp
hmm ok thanks.. I've found this
Code:
<% =FormatNumber(12345.67899, 3) %>
Output:
12,345.679
the '3' in that example decides decimal places. If you just use
<% =FormatNumber(12345.67899) %>
the fefault output gives 2 decimal place, so 12346.68. The value I will be using will always be a whole number, so presumably I would use something like
<% =FormatNumber(50000000, 0) %>
to get an output of 50,000,000. However I cannot seem to get the syntax correct, especially because the number is going to be a variable, such as
<% =FormatNumber(" & value & ", 0) %>
so I'm still at a loss here.. any more suggestions?
GOT IT :)
fyi this is how it worked.. hope someone will find this useful..
sub expreport (strTriggerName, trig_line, arrWildCards)
dim exp
exp = FormatNumber(World.GetVariable("exp"), 0)
world.EchoInput = 0
World.send "grouptell unused exp : " & exp & ""
world.EchoInput = 1
end sub
It was me who mentioned this before in another thread. It's just one of the many projects on my "to-do" list. (I want to format all numbers larger than 4 digits). It would involve using colour tells to replace the output in the exact same colours, if possible. Low prioroty project, since it is just cosmetic... This thread will be useful if and when I ever get to it.
kewl :) glad it's a help. Shouldn't take long to do, just set the trigger (with omit output) to set the variable for whatever you want it for, and the same script can then recall that variable and spit it out as a tell with the commas in it as above.
Not sure if this is the same for all muds, but color codes you can add into the tell message.. these are the ones I use; just add them inside the world.send "tell message" and you're done.
colors:
\c12 = white
\c13 = blue
\c14 = yellow
\c15 = green
\c16 = purple
\c17 = red
effects:
\ao1 = code end
\a02 = bright
\a03 = dull
\a05 = underline
\a06 = flashing
\a08 = highlight
actually, i can only use these on grouptells in the mud I play. person to person tells are set by default and wont recognize those codes. Judging by your knowledge on these forums, you probably know all this anyway. :/
Well, a couple of things I'll have to look at, if/when I take on this project:
- Trigger will just be a regular expression matching on 4 digits or more: \d{4,}
- I will need the whole line omitted since I need to reprint the entire line using a series of World.Colourtell functions.
- Scripted "World.Send" and "World.Note" functions always display a blank line after the last such statement in the script, and if I'm gonna do this for costmetic improvement, this make it unworthwile.
- There are tons of 4+ digit numbers... I don't know if I want the lag of triggering on every one. Would 2 different numbers on the same line be hard to handle?
...Until the blank line thing is fixed in MUSHclient, I don't think I will ever bother with this project.
World.tell doesn't display the blank line, will that help?
Yes, but using world.tell then messes up the output to a log file, which seems to follow the correct structure, unlike the display output.
I would use "World.Colourtell" for each instance there was a style change in the captured line. (For the most part, on my main mud, there are never style changes mid line). I would then force the line end by using a "World.Note"
For each Stylechange in CapturedLine
World.Colourtell Current Syle
Next
World.Note " "
This seems to be the practical way to do use multiple style type on one line. Complete the line with a single World.Note.
This is all speculation, I haven't fiddled with such code.
Ah, yes, but then you're trying to program around something that really appears to be an internal problem.
I've checked things that were mentioned in a few other threads, tried to delete any extra carriage returns in the trigger(weren't there), checked for potential excess carriage returns either via an extra world.Note or forced carriage return in scripting(didn't find it).
If you are able to make it happen, and you turn on file logging, you'll notice that it works correctly(with respect to carriage returns) in the log file.
Also, if the line following the world.Note that causes the extra blank line is gagged for any reason, evidently that gag will cause the blank line to be removed.
My only guess is that somehow the trigger matching misses the carriage return on the end of the line, or matches the carriage return to the beginning of the line and the one on the end is being left, causing a temporary double entry. As the log file seems to work correctly, I have trouble believing that fully though.
Right now, comparing how the log file pushes out data to how the display pushes it out would probably be a good start, especially focusing on triggers with world.Note and following the world.Note with a trigger that will gag the following line.
It's been around since I started using MushClient 3.17, but it's mostly ignorable and only a bit annoying. Since others seem to be mentioning it now though, here's the facts as I've seen them.