| 12-06-2002, 04:47 AM | #1 |
it doesn't give the length of the _letters_ it gives some odd number. (but is still thee string length) i'm sure it works i use it in my voting system. used it to compare lengths, do substrings or whatever you would do with lengths =) PHP Code:
|
| 01-09-2003, 02:19 AM | #2 |
Good Attempt, Azumarril, and it works for the most part. But putting a slash on the end isnt necessary, all you need to do is check for the null string, "". That will tell you that you are at the end of the string. Furthermore, you can use local variables by typing local vartype varname, this is a lot more helpful than requiring your users to have global variables. If you impose a limit on the user, you shoudl include that limit as a function argument, also you should always remove the doNothing()'s because they might actually be a procedure that is called by the interpreter (akkk). And you dont need the else since you only have one branch. Heres an updated trigger. PHP Code:
Anyway, good work (it will run faster if you take the procedures out of it if the interpreter actually puts them on the invocation stack). Nice to see that some people are taking the time to post working triggers here, thanks azumarril. FM_TertiaryEye |
| 01-09-2003, 02:44 AM | #3 |
thanks =P but my wc3 editor won't except local variables so eh and if the current len pointer is 1 why subtract 1? |
| 01-09-2003, 10:03 AM | #4 |
Even the modified editor lets you have local vars i think, what editor do you use? :abomHUH?: Just add the local vars in on top of all your other code for any function and it should work fine. Anyway, the subtring function starts reading at 1 because substring("a", 1, 1) is a, if you throw it a zero this substring function will always return null and all your string lengths will be zero. So thats why it starts at 1 and what happens is that as its reading, it gets set to the null character when its one past the length, for example: a string ______^ 1234567 As you can see, the function has to stop one past the length of the string, because it has to read the null character at the end. So therefore to get the true physical length, you have to back it up one. BTW: I just added a handle for the null string case, a player cant enter a null string but someone using a trigger can. FM_TertiaryEye |
| 01-09-2003, 10:28 PM | #5 | |
I use normal WE... i ment Quote:
|
| 01-10-2003, 12:14 PM | #6 |
If you add a else could't you remove the set strLen = strLen - 1 ? PHP Code:
|
| 01-10-2003, 10:45 PM | #7 |
ok good job you can use either mothods. topic closed =D |
