Hi!
I've searched the forum & help file, but I'm not finding the answer on this one.
Is there an escape character which can be used for including a " in a string?
Normally it's \, but that's not working.
Any help or advice appreciated,
Thanx in advance.
Quotes escape character for strings
Moderators: David Barker, Jerry Messina
- Senacharim
- Posts: 139
- Joined: Tue Aug 10, 2010 5:19 pm
- Location: Ventura, CA
Quotes escape character for strings
Surviving Member
Bermuda Triangle Battalion
from 2026 to 1992
Voted "Most likely to time travel"--Class of 2024.
Bermuda Triangle Battalion
from 2026 to 1992
Voted "Most likely to time travel"--Class of 2024.
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact:
There are a number of ways you can do this
or
The first code example is far more efficient in terms of MCU resources than the second example.
Code: Select all
include "usart.bas"
setbaudrate(br19200)
write("hello ",34,"world",34)
write(13,10)
Code: Select all
include "usart.bas"
dim myString as string
myString = "Hello " + #34 + "World" + #34
setbaudrate(br19200)
write(myString,13,10)
- Senacharim
- Posts: 139
- Joined: Tue Aug 10, 2010 5:19 pm
- Location: Ventura, CA
Could one do something like:
??
Wait, it occurs to me I can test this myself... let's see...
[time passes]
Ah, so, no the above does not work, also does not work.
Alright, so after piddling with it,does not work, but DOES work.
Odd.
Oh well.
Thanks.
Code: Select all
Dim TehString as String
TehString = 34, "Hello World", 34
Wait, it occurs to me I can test this myself... let's see...
[time passes]
Ah, so, no the above does not work,
Code: Select all
TehString = char(34) + "Hello World!" + Char(34)
Alright, so after piddling with it,
Code: Select all
TehString = char(34) + "Hello World!" + Char(34)
MY_LCD.Write(TehString)
Code: Select all
TehString = "Hello World!"
MY_LCD.Write(Char(34))
MY_LCD.Write(TehString)
MY_LCD.Write(Char(34))
Odd.
Oh well.
Thanks.
Surviving Member
Bermuda Triangle Battalion
from 2026 to 1992
Voted "Most likely to time travel"--Class of 2024.
Bermuda Triangle Battalion
from 2026 to 1992
Voted "Most likely to time travel"--Class of 2024.
-
- Swordfish Developer
- Posts: 1473
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
I can see why some of the syntax posted wouldn't work, but I just happened to try
Looks like there's something funny with the third case, and the compiler doesn't like it.
Code: Select all
dim s as string
s = char(34) + "ABC" // works... s = DB 0X22, 0X41, 0X42, 0X43, 0X00
s = "ABC" + char(34) // works... s = DB 0X41, 0X42, 0X43, 0X22, 0X00
s = char(34) + "ABC" + char(34) // DOESN'T work... s = DB 0X41, 0X42, 0X43, 0X00
s = #34 + "ABC" + #34 // DOESN'T work... same as previous
s = "AB" + char(34) + "CD" + char(34) // works... s = DB 0X41, 0X42, 0X22, 0X43, 0X44, 0X22, 0X00
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact: