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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ Few things...

Few things...

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


Posted by Erendil   (3 posts)  Bio
Date Fri 17 May 2002 04:09 PM (UTC)
Message
1) How can I read words from text file?
Top

Posted by Erendil   (3 posts)  Bio
Date Reply #1 on Fri 17 May 2002 04:29 PM (UTC)
Message
And one more:

I have script which display number of killed monsters.
For example:

bugs - 3
dragons - 12
demons - 321

But I want to make it like this:

bugs - 003
dragons - 012
demons - 321

How can I do this?
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #2 on Fri 17 May 2002 06:41 PM (UTC)
Message

Function PadNumber(NumberString, Length)
  Dim StringLength
  Dim x
  NumberString = CStr(NumberString)
  StringLength = Len(NumberString)
  If StringLength < Length Then
    For x = 1 to (Length - StringLength)
      NumberString = "0" & NumberString
    Next
  End If
  PadNumber = NumberString
End Function

You would then use the function elsewhere in your script, like this:

Killed_Bugs = PadNumber(Killed_Bugs, 3)
Killed_Demons = PadNumber(Killed_Demons, 3)

The first argument is the string you want formatted.

The second argument is how many characters you want the WHOLE string to be.

Optionally, you may not want to change the value in your counter variables, but instead just format the values on the fly as you display them:

World.Note "Killed mobs:"
World.Note "------------"
World.Note "Bugs   : " & PadNumber(Killed_Bugs, 3)
World.Note "Demons : " & PadNumber(Killed_Demons, 3)

This would leave your variables intact, yet format them in a nice readable manner. :)

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

Constantly proving I don't know what I am doing...
Magnum.
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.


13,698 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.