| 07-03-2006, 01:37 PM | #1 |
Ok, i decided to make a function that returns the position of a letter in a string. Here it is: JASS:function CF_FindLetter takes string whichCharacter, integer letterCount, string source returns integer local integer i = 1 local integer newCount = letterCount if(StringLength(whichCharacter) == 1) then loop exitwhen i == StringLength(source) if(SubString(source, i-1, i) == whichCharacter) then if(letterCount == 0) then return i endif set letterCount = letterCount - 1 endif set i = i + 1 endloop endif return 0 endfunction Any help? Edited because: Changed to Griff's post. |
| 07-03-2006, 01:41 PM | #2 |
Replace: JASS:if(SubString(source, i, i) == whichCharacter) then With: JASS:if(SubString(source, i-1, i) == whichCharacter) then Oh, and define i as 1 to begin with. |
| 07-03-2006, 02:00 PM | #3 |
Hmm, ok. Using (1, 1) has worked in the past for the first letter though, i think that was because it was GUi and the SubStringBJ uses -1. Which i just realised lol. Thanks for poiting that out. |
