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

Help with Quotes

Started by lebuildman, 25 September 2014 - 08:23 PM
lebuildman #1
Posted 25 September 2014 - 10:23 PM
I'm making a program called "LogoDraw". It's a simple program thats help with the logo table of the logoDraw API that's gonna be used in my Universal App Store project. My problem is: The program store all in tables inside tables, and… I need to place a Quote in a string to mark a String in a Table!

The Entire Technicaw Code is this, being c1 to c9 color strings and t1 to 19 one-letter string:

final = "{{{""..c1.."",""..t1..""},{""..c2.."",""..t2..""},{""..c3.."",""..t3..""}},{{""..c4.."",""..t4..""},{""..c5.."",""..t5..""},{""..c6."",""..t6..""}},{{""..c7.."",""..t7..""},{""..c8.."",""..t8..""},{""..c9.."",""..t9..""}}}"
The Strings need to be setted with a String… The Final varible will be writed in a file to use this code in my UAS Project. And… How I place a Quote here…

Lua have a Way to Tresspass the "Quote Limitation" with some kind of variable/symbol of other way??
Dragon53535 #2
Posted 25 September 2014 - 10:47 PM
So you're wanting to put a table, and all it's parts, into a string. I'm pretty sure that textutils.serialize() will help you with that as it's the way to write table contents to a file to read later using textutils.unserialize(). textutils.serialize(tablename) turns the table into a string, and i do believe it shows {}. while using textutils.unserialize(serializedString) will return the table in full.

Edit: Thank's Yami… I seem to type too fast for my own good.
Edited on 26 September 2014 - 02:56 AM
KingofGamesYami #3
Posted 25 September 2014 - 11:45 PM
while using textutils.serialize(serializedString) will return the table in full.

Correction: textutils.unserialize(serializedString)
Bomb Bloke #4
Posted 26 September 2014 - 12:38 AM
textutils.serialize() is indeed the way to go here, but if you did specifically need to stick a quote into a string, you'd generally do it using the backslash escape character.

Eg:

local myQuoteInAString = "\""
print(myQuoteInAString)
lebuildman #5
Posted 26 September 2014 - 01:34 AM
Thx. I'll test Serialize() and I'll remember the Backslash when I need to Quote something and Lua won't allow :P/>
Dragon53535 #6
Posted 28 September 2014 - 01:22 AM
Thx. I'll test Serialize() and I'll remember the Backslash when I need to Quote something and Lua won't allow :P/>
You could potentially use the other quote inside and it ignores it such as "Hello there 'Bob'" would be printed as Hello there 'Bob'