No Mid() or Instr()?
Monkey Forums/Monkey Programming/No Mid() or Instr()?
| ||
How do I parse a string and retrieve a character/characters starting from Position n? |
| ||
Check this post: http://www.monkeycoder.co.nz/Community/posts.php?topic=269 |
| ||
I checked that post. What does the .. mean? "Return str[pos..pos+size]" I have not seen this .. before. |
| ||
The two dots are used to get a substring (or slice) of a string. They say, get from position "pos" to "pos+size" and return. It's similar to the python substring, e.g. str[pos:pos2]. Example Code Local str$ = "Hello World" Print str[6..11] 'Prints "World" |
| ||
Hey Goodlooking! Oh, so it's like a mid string kind of function. I see! I'm guessing though in your examples it would print out " World" ? Cheers for the tip. |
| ||
The example should print out "World" Strings start from 0 and work like this or at least in most languages they should. 0|H 1|e 2|l 3|l 4|o 5| 6|W 7|o 8|r 9|l 10|d 11|EOF |
| ||
Cheers, that makes sense. Up till now, every version of Blitz has always started at 1 in a string and not from 0. |