Upper to lower case

Posted by Penguin on Mon 27 May 2002 01:56 AM — 4 posts, 18,398 views.

#0
Hi! I've been trying to make an alias to send "trigger Loser todo hunt loser" I tried to write a script which turned out something like this:

Sub OnHunt (strTriggerName, strLine, arrWildCards)
person1= arrWildcards (1)
person1= ucase (person)
person = arrWildcards (1) '
person = lcase (person) '
World.Send "trigger person1 todo hunt " + person
End Sub

Alias: pkhunt *
Expand variables checked
Label: PK_hunt
Script: OnHunt

However if I typed pkhunt loser, the mud registers it as trigger person1 todo hunt loser
Do you know what the problem is here?
#1
The first thing is that 'person1' should be added into the string similar to how you did it with 'person'

I also changed the 'ucase (person)' to 'ucase (person1)' as I believe you meant to do.


Sub OnHunt (strTriggerName, strLine, arrWildCards)
  person1 = arrWildcards (1)
  person1 = ucase (person1)
  person  = arrWildcards (1) '
  person  = lcase (person) '
  World.Send "trigger " + person1 + " todo hunt " + person
End Sub 



The second thing, is that UCase() in VBScript will capitalize the whole word. The output you probably want is as follows:


Sub OnHunt (strTriggerName, strLine, arrWildCards)
  person1 = arrWildcards(1)
  person1 = ucase(Left(person1, 1)) + lcase(Mid(person1, 2, Len(person1)))
  person  = arrWildcards(1)
  person  = lcase(person)
  World.Send "trigger " + person1 + " todo hunt " + person
End Sub 



And for a final possible product:


Sub OnHunt (strTriggerName, strLine, arrWildCards)
  Dim person
  
  person = arrWildcards(1)
  person = UCase(Left(person, 1)) & LCase(Mid(person, 2, Len(person)))

  World.Send "trigger " & person & " todo hunt " & LCase(person)
End Sub 
#2
Hmm.. what if I want to use this alias on a previously set variable? Let's say I have a target "penguin" Do you think there is anyway I can set an alias "h" using VBscript to send "trigger Penguin todo hunt penguin"
#3
Depending on if you're using an internal MushClient variable, or a global VBScript variable, delete the incorrect line.


Dim target_name   ' Only needed if you store it as a global variable in the VBScript instead of a MushClient variable

Sub OnHunt (strTriggerName, strLine, arrWildCards)
  Dim person
  
'  person = arrWildcards(1)                    ' Don't pull it from the trigger/alias data
  person = world.GetVariable("target_name")    ' Data is stored in a MushClient variable
  person = target_name                         ' Data is stored in a VBScript global variable
  person = UCase(Left(person, 1)) & LCase(Mid(person, 2, Len(person)))

  World.Send "trigger " & person & " todo hunt " & LCase(person)
End Sub