This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Sirharry0077's profile picture

[Lua] Print Quotes

Started by Sirharry0077, 16 February 2013 - 06:58 AM
Sirharry0077 #1
Posted 16 February 2013 - 07:58 AM
How would you go about doing the following without error?

print("Type "exit" To Exit")
NDFJay #2
Posted 16 February 2013 - 08:16 AM
simple fix, use this

print('Type "exit" to exit')

There's two types of string syntax for printing, there the single quote ' and double quote " if you want to print a double quote the surround the rest of the string in a single quote and visa versa

Hope this helps you
LBPHacker #3
Posted 16 February 2013 - 08:34 AM
And of course you can just escape it
 print("this is a quotation mark: \" - what a surprise!") 
Kingdaro #4
Posted 16 February 2013 - 08:43 AM
I'll go ahead and add that you can use double brackets too. They're best for strings in multiple lines, and maybe if you want to use both double and single quotes.


s = [[ a string
with mutiple lines
with 'single' and "double" quotes! ]]
Sirharry0077 #5
Posted 16 February 2013 - 08:47 AM
Thx guys everything you posted is helpful.