No Mid() or Instr()?

Monkey Forums/Monkey Programming/No Mid() or Instr()?

GfK(Posted 2011) [#1]
How do I parse a string and retrieve a character/characters starting from Position n?


therevills(Posted 2011) [#2]
Check this post:

http://www.monkeycoder.co.nz/Community/posts.php?topic=269


ENAY(Posted 2011) [#3]
I checked that post. What does the .. mean?

"Return str[pos..pos+size]"

I have not seen this .. before.


Goodlookinguy(Posted 2011) [#4]
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"



ENAY(Posted 2011) [#5]
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.


Goodlookinguy(Posted 2011) [#6]
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



ENAY(Posted 2011) [#7]
Cheers, that makes sense. Up till now, every version of Blitz has always started at 1 in a string and not from 0.