Register forum user name Search FAQ

Gammon Forum

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.
 Entire forum ➜ MUSHclient ➜ VBscript ➜ adding commas to large numerical values

adding commas to large numerical values

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Guest1   USA  (256 posts)
Date Tue 01 Oct 2002 10:07 AM (UTC)
Message
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. :)
Top

Posted by Vaejor   (120 posts)  Bio
Date Reply #1 on Tue 01 Oct 2002 01:41 PM (UTC)
Message
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctformatnumber.asp
Top

Posted by Guest1   USA  (256 posts)
Date Reply #2 on Tue 01 Oct 2002 03:37 PM (UTC)
Message
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?
Top

Posted by Guest1   USA  (256 posts)
Date Reply #3 on Tue 01 Oct 2002 04:32 PM (UTC)
Message
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
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #4 on Tue 01 Oct 2002 07:53 PM (UTC)
Message
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.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Guest1   USA  (256 posts)
Date Reply #5 on Tue 01 Oct 2002 08:10 PM (UTC)
Message
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. :/
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #6 on Wed 02 Oct 2002 02:34 AM (UTC)
Message
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.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #7 on Fri 04 Oct 2002 12:57 AM (UTC)
Message
World.tell doesn't display the blank line, will that help?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Vaejor   (120 posts)  Bio
Date Reply #8 on Fri 04 Oct 2002 01:32 AM (UTC)
Message
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.
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #9 on Fri 04 Oct 2002 04:27 AM (UTC)
Message
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.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Vaejor   (120 posts)  Bio
Date Reply #10 on Sat 05 Oct 2002 07:05 PM (UTC)
Message
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.
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.


32,359 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.