4 posts
Posted 09 January 2013 - 12:00 AM
Is it possible to write a "\" in ComputerCraft?
Evertime I get a unfinished String error…
7508 posts
Location
Australia
Posted 09 January 2013 - 12:01 AM
In programming languages \ is a terminating character. meaning that \n actually means new line, or \t means tab. this means that if we want strings for example with a " ' or \ we need to place a \ in front of it… so \ is actually \\ in a string… hope this helps :)/>
1054 posts
Posted 09 January 2013 - 12:03 AM
You need to escape it, this means prepending it with another '\'. Example:
print("\\backslash")
You can do the same for quotes and other special characters. Quotes could be printed like:
print(" \"double quotes\" ")
Edit: heavily ninja'd. On a side note, you can also use [[ ]] to surround your strings, this ignores every special character. E.g.:
print( [[I can put "quotes" and \backslashes here
and even newlines if I want to!]] )
4 posts
Posted 09 January 2013 - 12:04 AM
Yes that worked thanks :D/>