656 posts
Posted 25 May 2014 - 07:31 PM
I want to do something like this:
local text = "/texthere\"
but it errors with "unfinished string", because the \ skips the next ". How do I fix this?
Edited on 25 May 2014 - 05:31 PM
570 posts
Posted 25 May 2014 - 07:38 PM
Escape the backslash with another backslash.
local text="/texthere\\"
656 posts
Posted 25 May 2014 - 07:45 PM
Escape the backslash with another backslash.
local text="/texthere\\"
Thanks!
61 posts
Posted 25 May 2014 - 07:46 PM
local text = string.char(47).."texthere"..string.char(92)
570 posts
Posted 25 May 2014 - 07:48 PM
local text = string.char(47).."texthere"..string.char(92)
Well, that's adventurous ;)/>! The slash doesn't need to be escaped, only the backslash, but it's an acceptable solution.
61 posts
Posted 25 May 2014 - 07:50 PM
Old habits die hard (VB6)!
656 posts
Posted 25 May 2014 - 09:35 PM
local text = string.char(47).."texthere"..string.char(92)
Are those numbers the same as the ones you get from os.pullEvent("char")?
1220 posts
Location
Earth orbit
Posted 25 May 2014 - 09:37 PM
local text = string.char(47).."texthere"..string.char(92)
Are those numbers the same as the ones you get from os.pullEvent("char")?
"char" just returns strings, if I remember correctly. Do you, perchance, mean os.pullEvent("key") ?
570 posts
Posted 25 May 2014 - 09:45 PM
Are those numbers the same as the ones you get from os.pullEvent("char")?
If you were to wrap the result in a string.byte(), yes. If, as Dog said, you meant os.pullEvent("key"), no. The numbers returned by the key event are
key codes.
61 posts
Posted 25 May 2014 - 09:49 PM
The numbers are the decimal equivalent of the ASCII system.
I had to use them a lot with VB6
string.char(X) is the same as Chr$(X) in VB
"\" has the ASCII code of 97
The full list is
here
7508 posts
Location
Australia
Posted 26 May 2014 - 12:14 AM
no one is going to mention this?
local text = [[/text here\]]
656 posts
Posted 26 May 2014 - 05:37 PM
no one is going to mention this?
local text = [[/text here\]]
That's definitely the most elegant solution!