New line in string ?

Monkey Targets Forums/Desktop/New line in string ?

Rushino(Posted 2013) [#1]
I am trying to make a new line in a string and then use SaveString to save the textfile.. but ~n doesn't seem to work and \r\n neither..

Any idea ?


dawlane(Posted 2013) [#2]
Use something like: str = "TESTING THE STRING." + String.FromChar(13) + "AND AGAIN TESTING THE STRING."
But it should be noted that it looks like DrawText doesn't recognise any cartridge returns etc. So you would have to parse the string and draw each character (or group of characters up to the control code) and handle any type of such control codes yourself.


Rushino(Posted 2013) [#3]
Thanks for the info! Well i just needed something for writting logs. But is there a reason ~n doesnt work for files?


dawlane(Posted 2013) [#4]
I wouldn't know the reason why Monk ignores escape sequences in some situations. Only Mark could tell you why it does and any thing I say would just be a guess. As far as I know all the monkey targets support string escape sequences and it could be something as simple as string file encoding ( especially when your dealing with Mac OSX string objects as the NSString class is a law onto it's self ).

So just to make it clear what you want to do within a string; it's always a good idea to explicitly include the ASCII character control code into that string.


Rushino(Posted 2013) [#5]
I found it.. actually it work with other program than Notepad.. like notepad++ but standard notepad seem to need a carriage return with a new line to make it work so its ~r~n instead of ~n when you save.