[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Here's a new one...
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Here's a new one...

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


Posted by David Berthiaume   (202 posts)  [Biography] 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?
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] 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'.
[Go to top] top

Posted by David Berthiaume   (202 posts)  [Biography] 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
[Go to top] 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.


4,724 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]