| 09-10-2002, 05:10 PM | #1 |
I am working on some stuff relating to Chat messages. Well I can get the Chat message into a string. This chat message is always 4 words long. The first one doesn't really matter but I need to be able to run test on the other 3 words individually. So putting all the words into integers would be the best I think. I talked to someone about doing that and they said I would have to use parsing to do that. The 3 last words would change length so I can't have a Predetremined length already set. If anyone know of a way to fix this please say so. This would help out tons. Thanx |
| 09-10-2002, 06:12 PM | #2 |
In JAVA there is a String propertie named lenght (I think), however, I do not know if JASS use same methods or properties than JAVA...sorry :( |
| 09-10-2002, 07:53 PM | #3 |
I couldn't find a function wich did string length, but I was just looking at the functions in the gui...I'd say terminate the string with a certain char, and take it 1 char at a time comparing the char to a space or the termination char...If you understood that... |
| 09-10-2002, 10:30 PM | #4 |
I sorta get you and sorta don't. I think I got what you meant, but do you know of a function that might do that and if explain how to pull it off. Thanks so far guys. I just found this in the Blizzard.j If you can figure it out before me please post. I think I can somehow use a loop and some stuff to get this to work. Is their a way I can compare until I get a space like What you were talking about?. //============================================= // The parameters for the API Substring function are unintuitive, // so this merely performs a translation for the starting index. // function SubStringBJ takes string source, integer start, integer end returns string return SubString(source, start-1, end) endfunction |
| 09-11-2002, 12:54 AM | #5 |
Yes, that is how you'd do it char by char, something along the lines of this (pseudo-code) for each int a from 1 to 9999999 (max length of string, whatever that may be) if (substring (str, a, a))==<a space>) then do set variable WordEnd[y]=a AND y=y+1 else if (substring(str, a, a) == <termination char>) then do break else do nothing Break might not be a possible thing in jass, in which case you'd just have the function return. In order to do 2 things in the action of the if statement you're going to have to convert to custom text. Termination char would be something that never appears in any text that will be typed in, and it needs to always be at the end, or you'll run into trouble here. (IE | or _ for it) You could also figure out what substring of a location in the string that doesn't exist returns and compare it to that. (thus the game won't crash if someone forgets to put a terminator. (there are other ways of doing that, only make the loop go to 99 for ex) |
| 09-11-2002, 04:47 AM | #6 |
I finally got my Parser Totally Done. It works Buglessly too. It will be realeasd with the Commander, but if anybody want's it earlier, find me on IRC, or email me. My email address is in my profile. Thanks dude you explained it but It still kind of floated my brain Was to sore from the headache I was getting. I took a brake came back on and tlaked to GoldenUrg and he explained it twice the second time I sort of got it. But some of the things mixed me up. So I sat down with ppaer and pencil and wrote most of it out. Then sent it to GoldenUrg after I was done. He checked some stuff, helped me fix one or two parts. I had to add one more feature and Debug the heck out of it till I got it All the way done. When I was done It turned out it can parse any ammount of words. So I would like to Thank Golden Urg and Newhydra for their help. |
