Few things...

Posted by Erendil on Fri 17 May 2002 04:09 PM — 3 posts, 14,401 views.

#0
1) How can I read words from text file?
#1
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?
Canada #2

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. :)