| 03-24-2004, 04:47 AM | #1 |
I have never worked with substrings but I plan to make a couple of triggers involving them. Would someone tell me how they work? |
| 03-24-2004, 02:31 PM | #2 |
The substring code conatains two numbers and you must define the sring you want. The first nuber stands for the place to start and the second for how many letters. So subsring (2,2) from "I am KaMux" gives "am". |
| 03-24-2004, 10:26 PM | #3 | |
Quote:
So if you say substring(2,2) it starts the substring on the 3rd character? So it skips the first two? |
| 03-25-2004, 07:47 PM | #4 | |
Quote:
Example would be: Code:
This_is_a_string! || SubString(1,2) -- Th | Substring(3,3) -- i |
| 03-25-2004, 11:22 PM | #5 |
On your second example you use Substring(3,3), but you only have the letter i. Wouldn't it be is_? |
| 03-25-2004, 11:44 PM | #6 |
No, becouse.... Legolas was correcting Kamux. What kamux said applies to typical programming languages like c++, byt certainly not JASS :P, Jass's SubString function uses the two values as Start and End characters. So (3,3) would return the characters from 3 too 3 (thus, 1 char). Oh, and be careful with the SubString and SubStringBJ difference, considering you're likely doing this in JASS. SubString BJ works like Legolas said (and I here). However, the native itself, SubString uses a more typical system, where the characters start from 0, so the first char is 0. AND, it takes all the characters in range from start to end, "EXCLUDING" end. So there, (1,1) would not return the first char....nor the second char, but (1,2) would return the second char (only). (0,1) would extract the first char. And thus, (0,StringLength(MyString)) would extract the whole string. Cubasis |
| 03-26-2004, 12:06 AM | #7 |
Thanks for clearing that up cubasis. Espically with the substring native thing. I get ticked off with blizzard making tons of BJ funcitons that run from a base 1 and then having all the natives go from a base 0. Stupidness, I mean it was kind of okay for me when I started a year and a half ago because I had no programming experince whatsoever, but if I had been made to go from a base 0 system it would have been a much easier transition into JASS. Now I know JAVA somewhat and am going to learn C++ next so I am having to use base 0 stuff constantly now. |
