| 12-02-2002, 11:27 PM | #1 |
Here is a Uppercase Function. It takes a string and Capitalizes the string, so that the first letter is upper case. You can run alreayd uppercase, numbers anything string, through it. It will only change ones that have a lower case as the first letter. Code:
//=================================================
// Ucase Function (by DKSlayer)
//=================================================
function Ucase takes string Ustring returns string
//Required Variables
local string Done
local integer Length = 1
local string Char
local string Rest
//Gets the length of the string
loop
exitwhen((SubStringBJ(Ustring,1,Length) == Ustring))
set Length = Length + 1
endloop
//Pulls first character, stores it into Char & the rest of the word into Rest
set Char = SubStringBJ(Ustring,1,1)
set Rest = SubStringBJ(Ustring,2,Length)
//Find Char's Upper Case Equivalent
if (Char == "a") then
set Char = "A"
elseif (Char == "b") then
set Char = "B"
elseif (Char == "c") then
set Char = "C"
elseif (Char == "d") then
set Char = "D"
elseif (Char == "e") then
set Char = "E"
elseif (Char == "f") then
set Char = "F"
elseif (Char == "g") then
set Char = "G"
elseif (Char == "h") then
set Char = "H"
elseif (Char == "i") then
set Char = "I"
elseif (Char == "j") then
set Char = "J"
elseif (Char == "k") then
set Char = "K"
elseif (Char == "l") then
set Char = "L"
elseif (Char == "m") then
set Char = "M"
elseif (Char == "n") then
set Char = "N"
elseif (Char == "o") then
set Char = "O"
elseif (Char == "p") then
set Char = "P"
elseif (Char == "q") then
set Char = "Q"
elseif (Char == "r") then
set Char = "R"
elseif (Char == "s") then
set Char = "S"
elseif (Char == "t") then
set Char = "T"
elseif (Char == "u") then
set Char = "U"
elseif (Char == "v") then
set Char = "V"
elseif (Char == "w") then
set Char = "W"
elseif (Char == "x") then
set Char = "X"
elseif (Char == "y") then
set Char = "Y"
elseif (Char == "z") then
set Char = "Z"
endif
//Gives us Upper Case String
set Done = Char + Rest
return Done
endfunctionThis can only be used in JASS. To install it just copy and it from here and paste it into your trigger. Make sure it is above the function you are calling it from. It can only take a string, although it should not bonk with other types. (Haven't tested this) I can safely run integers through it, it won't change it since they are not a letter. Look for examples below. Some examples of use Code:
set StrWord = Ucase(StrWord)
call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 5, Ucase("jump"))It's as easy as that. Please Post any questions or comments or bugs here. Also if you want me to post an example map just ask and I will make one for you. :) Thanks DKSlayer |
| 12-03-2002, 02:56 AM | #2 |
Er, um, why would you want to do this? |
| 12-03-2002, 03:31 PM | #3 |
I do this becuase I allow a person to enter a lowercase word or uppercase, But I don't feel like having an or for every command (ChatMsg == Bob) or (ChatMsg == bob) that would work but rather annoying. So you would only use this for String Comparisions, like chat messages. Not many people use this now, but maybe later. |
| 12-03-2002, 07:19 PM | #4 |
But what if the guy is a mad man and types it like...BoB? I think it better if you make your function uppercase the entire string entered that way you can avoid the insane man babble and its easier that way... |
| 12-03-2002, 07:31 PM | #5 |
I could make a version that does that, I liked this one because I display thos strings also, not just for comparision. When I get home I will post the Upcase all Version. |
| 12-05-2002, 01:17 AM | #6 |
I didn't know that it was case sensitive. |
| 12-05-2002, 04:46 AM | #7 |
Case Senesitive what? The Commander is sorta that way, and anything else I use to compare strings. Hmmm, Actually I never tested that, the main reason I made it was so that when it displayed those strings back they would look nicer. |
