Getting slices from strings, how to make it work?
BlitzMax Forums/BlitzMax Beginners Area/Getting slices from strings, how to make it work?
| ||
Local sSource:String Local sTest:String sSource = "This is a test" sTest = sSource[1] Print sTest Print sSource[1] given that source code if i run it, it prints 104 104 and not h h which is what i was expecting why is that? And how do i fix it without using Mid (i want to use slices) How come Print sSource[1..] prints his is a test but Print sSource[1..1] prints nothing? I'm confused. Note: I've search the site and the examples/posts i found described this as working: http://www.blitzmax.com/Community/posts.php?topic=59682#665364 |
| ||
print sSource[..1]? |
| ||
.. what if i want the 5th character i dont want to print it either, its just for debut purposes I want it to be assigned to sTest so if i print sTest, it will show the correct string |
| ||
sSource[5..6] Or it might be [4..5], I can't be bothered to check at the moment. You can probably figure it out from there. As for getting a number from s[i], s[i] returns the unicode character, not a string. |
| ||
Print sSource[4..5] |
| ||
. (too slow) |
| ||
So basicaly, slicing ( [a..b] ) works from a to b-1? |
| ||
... from a for length (b-a)... The length of the returned slice is always EndIndex - StartIndex elements long, .. Blitzmax help files. |
| ||
thanks alot |