Print only a part from a string [solved]
Monkey Forums/Monkey Programming/Print only a part from a string [solved]| 
 | ||
| I want to make a simple effect to draw a text character by character with a pause between them. I am loading my text into a string. How to print only the first X characters of the string? | 
| 
 | ||
| Read the about the String type in the documentation. http://www.monkey-x.com/docs/html/Programming_Language%20reference.html#types The answer is in there. | 
| 
 | ||
| You can just create a substring 
Function Main()
    Local myString:="Hello world!"
    Print myString[..1]
    Print myString[..2]
    Print myString[..3]
    Print myString[..4]
End
This outputs: H He Hel Hell | 
| 
 | ||
| thank you dawlane. I found what I needed there. Edit: @ziggy: you posted while I was replying and that code gave me the perfect idea :D thanks | 
| 
 | ||
| Notice you can use negative indexes to get latest chars insted of first chars. I found that very useful | 
| 
 | ||
| I would have thought that a negative index would have thrown an index out of range error. | 
| 
 | ||
| @ziggy: wow. that a nice effect. | 
| 
 | ||
| It's a documented implementation detail, not a side effect or anything like this, and sometimes it's quite handy! |